yolkbot 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +200 -1
  4. package/dist/bot/GamePlayer.js +74 -1
  5. package/dist/bot.js +1679 -1
  6. package/dist/comm/CommIn.js +79 -1
  7. package/dist/comm/CommOut.js +60 -1
  8. package/dist/comm/index.js +11 -1
  9. package/dist/constants/CloseCode.js +27 -1
  10. package/dist/constants/CommCode.js +53 -1
  11. package/dist/constants/challenges.js +1821 -1
  12. package/dist/constants/findItemById.js +2 -3
  13. package/dist/constants/guns.js +277 -1
  14. package/dist/constants/index.js +139 -1
  15. package/dist/constants/items.js +45042 -1
  16. package/dist/constants/maps.js +1263 -1
  17. package/dist/constants/regions.js +30 -1
  18. package/dist/dispatches/BanPlayerDispatch.js +32 -1
  19. package/dist/dispatches/BootPlayerDispatch.js +21 -1
  20. package/dist/dispatches/ChatDispatch.js +32 -1
  21. package/dist/dispatches/FireDispatch.js +15 -1
  22. package/dist/dispatches/GameOptionsDispatch.js +66 -1
  23. package/dist/dispatches/GoToAmmoDispatch.js +38 -1
  24. package/dist/dispatches/GoToCoopDispatch.js +38 -1
  25. package/dist/dispatches/GoToGrenadeDispatch.js +38 -1
  26. package/dist/dispatches/GoToPlayerDispatch.js +39 -1
  27. package/dist/dispatches/GoToSpatulaDispatch.js +26 -1
  28. package/dist/dispatches/LookAtDispatch.js +35 -1
  29. package/dist/dispatches/LookAtPosDispatch.js +29 -1
  30. package/dist/dispatches/MeleeDispatch.js +26 -1
  31. package/dist/dispatches/MovementDispatch.js +26 -1
  32. package/dist/dispatches/PauseDispatch.js +18 -1
  33. package/dist/dispatches/ReloadDispatch.js +28 -1
  34. package/dist/dispatches/ReportPlayerDispatch.js +42 -1
  35. package/dist/dispatches/ResetGameDispatch.js +19 -1
  36. package/dist/dispatches/SaveLoadoutDispatch.js +105 -1
  37. package/dist/dispatches/SpawnDispatch.js +22 -1
  38. package/dist/dispatches/SwapWeaponDispatch.js +25 -1
  39. package/dist/dispatches/SwitchTeamDispatch.js +33 -1
  40. package/dist/dispatches/ThrowGrenadeDispatch.js +21 -1
  41. package/dist/dispatches/index.js +74 -1
  42. package/dist/env/fetch.js +97 -10
  43. package/dist/env/globals.js +15 -1
  44. package/dist/index.js +14 -2
  45. package/dist/matchmaker.js +141 -1
  46. package/dist/pathing/astar.js +55 -1
  47. package/dist/pathing/binaryheap.js +79 -1
  48. package/dist/pathing/mapnode.js +179 -1
  49. package/dist/socket.js +97 -1
  50. package/dist/util.js +68 -1
  51. package/dist/wasm/bytes.js +8 -1
  52. package/dist/wasm/direct.js +84 -1
  53. package/dist/wasm/legacy.js +170 -1
  54. package/dist/wasm/util.js +19 -1
  55. package/package.json +38 -39
  56. /package/dist/{types/api.d.ts → api.d.ts} +0 -0
  57. /package/dist/{types/bot → bot}/GamePlayer.d.ts +0 -0
  58. /package/dist/{types/bot.d.ts → bot.d.ts} +0 -0
  59. /package/dist/{types/comm → comm}/CommIn.d.ts +0 -0
  60. /package/dist/{types/comm → comm}/CommOut.d.ts +0 -0
  61. /package/dist/{types/comm → comm}/index.d.ts +0 -0
  62. /package/dist/{types/constants → constants}/CloseCode.d.ts +0 -0
  63. /package/dist/{types/constants → constants}/CommCode.d.ts +0 -0
  64. /package/dist/{types/constants → constants}/challenges.d.ts +0 -0
  65. /package/dist/{types/constants → constants}/changelog.d.ts +0 -0
  66. /package/dist/{types/constants → constants}/findItemById.d.ts +0 -0
  67. /package/dist/{types/constants → constants}/guns.d.ts +0 -0
  68. /package/dist/{types/constants → constants}/housePromo.d.ts +0 -0
  69. /package/dist/{types/constants → constants}/index.d.ts +0 -0
  70. /package/dist/{types/constants → constants}/items.d.ts +0 -0
  71. /package/dist/{types/constants → constants}/language.d.ts +0 -0
  72. /package/dist/{types/constants → constants}/maps.d.ts +0 -0
  73. /package/dist/{types/constants → constants}/notices.d.ts +0 -0
  74. /package/dist/{types/constants → constants}/regions.d.ts +0 -0
  75. /package/dist/{types/constants → constants}/shellNews.d.ts +0 -0
  76. /package/dist/{types/constants → constants}/shellYoutube.d.ts +0 -0
  77. /package/dist/{types/constants → constants}/shopItems.d.ts +0 -0
  78. /package/dist/{types/constants → constants}/sounds.d.ts +0 -0
  79. /package/dist/{types/dispatches → dispatches}/BanPlayerDispatch.d.ts +0 -0
  80. /package/dist/{types/dispatches → dispatches}/BootPlayerDispatch.d.ts +0 -0
  81. /package/dist/{types/dispatches → dispatches}/ChatDispatch.d.ts +0 -0
  82. /package/dist/{types/dispatches → dispatches}/FireDispatch.d.ts +0 -0
  83. /package/dist/{types/dispatches → dispatches}/GameOptionsDispatch.d.ts +0 -0
  84. /package/dist/{types/dispatches → dispatches}/GoToAmmoDispatch.d.ts +0 -0
  85. /package/dist/{types/dispatches → dispatches}/GoToCoopDispatch.d.ts +0 -0
  86. /package/dist/{types/dispatches → dispatches}/GoToGrenadeDispatch.d.ts +0 -0
  87. /package/dist/{types/dispatches → dispatches}/GoToPlayerDispatch.d.ts +0 -0
  88. /package/dist/{types/dispatches → dispatches}/GoToSpatulaDispatch.d.ts +0 -0
  89. /package/dist/{types/dispatches → dispatches}/LookAtDispatch.d.ts +0 -0
  90. /package/dist/{types/dispatches → dispatches}/LookAtPosDispatch.d.ts +0 -0
  91. /package/dist/{types/dispatches → dispatches}/MeleeDispatch.d.ts +0 -0
  92. /package/dist/{types/dispatches → dispatches}/MovementDispatch.d.ts +0 -0
  93. /package/dist/{types/dispatches → dispatches}/PauseDispatch.d.ts +0 -0
  94. /package/dist/{types/dispatches → dispatches}/ReloadDispatch.d.ts +0 -0
  95. /package/dist/{types/dispatches → dispatches}/ReportPlayerDispatch.d.ts +0 -0
  96. /package/dist/{types/dispatches → dispatches}/ResetGameDispatch.d.ts +0 -0
  97. /package/dist/{types/dispatches → dispatches}/SaveLoadoutDispatch.d.ts +0 -0
  98. /package/dist/{types/dispatches → dispatches}/SpawnDispatch.d.ts +0 -0
  99. /package/dist/{types/dispatches → dispatches}/SwapWeaponDispatch.d.ts +0 -0
  100. /package/dist/{types/dispatches → dispatches}/SwitchTeamDispatch.d.ts +0 -0
  101. /package/dist/{types/dispatches → dispatches}/ThrowGrenadeDispatch.d.ts +0 -0
  102. /package/dist/{types/dispatches → dispatches}/index.d.ts +0 -0
  103. /package/dist/{types/matchmaker.d.ts → matchmaker.d.ts} +0 -0
  104. /package/dist/{types/pathing → pathing}/astar.d.ts +0 -0
  105. /package/dist/{types/pathing → pathing}/binaryheap.d.ts +0 -0
  106. /package/dist/{types/pathing → pathing}/mapnode.d.ts +0 -0
  107. /package/dist/{types/socket.d.ts → socket.d.ts} +0 -0
  108. /package/dist/{types/util.d.ts → util.d.ts} +0 -0
  109. /package/dist/{types/wasm → wasm}/bytes.d.ts +0 -0
  110. /package/dist/{types/wasm → wasm}/direct.d.ts +0 -0
  111. /package/dist/{types/wasm → wasm}/legacy.d.ts +0 -0
  112. /package/dist/{types/wasm → wasm}/util.d.ts +0 -0
@@ -1 +1,170 @@
1
- import{wasmBytes as w}from"./bytes.js";import{calculateMovements as m}from"./util.js";export class WASM{wasm;debug=!1;canvasListeners={};mockElement={textContent:""};processDate=null;processListeners=[];async initWasm(){const n=await WebAssembly.instantiate(w,this.getImports());this.wasm=n.instance.exports;this.wasm.start();const[s,_]=this.passStringToWasm([...Array(14)].map(()=>Math.random().toString(36)[2]).join(""));this.wasm.set_mouse_params(50,1,1,!1,s,_);const e=Math.floor(Math.random()*10)+1,t=Math.floor(Math.random()*10)+1;this.canvasListeners.pointermove({movementX:e,movementY:t})}getStringFromWasm=(n,s)=>{if(!this.wasm)return"";n>>>=0;return new TextDecoder().decode(new Uint8Array(this.wasm.memory.buffer).subarray(n,n+s))};passStringToWasm=(n)=>{if(!this.wasm)return;const s=new TextEncoder().encode(n),_=this.wasm.__wbindgen_malloc(s.length,1)>>>0;new Uint8Array(this.wasm.memory.buffer).subarray(_,_+s.length).set(s);return[_,s.length]};addToExternrefTable=(n)=>{if(!this.wasm)return;const s=this.wasm.__externref_table_alloc();this.wasm.__wbindgen_export_2.set(s,n);return s};getImports(){const n=new FinalizationRegistry((e)=>{this.wasm.__wbindgen_export_5.get(e.dtor)(e.a,e.b)}),s=(e,t,r,i)=>{const a={a:e,b:t,cnt:1,dtor:r},o=(...b)=>{a.cnt++;const c=a.a;a.a=0;try{return i(c,a.b,...b)}finally{if(--a.cnt===0){this.wasm.__wbindgen_export_5.get(a.dtor)(c,a.b);n.unregister(a)}else a.a=c}};o.original=a;n.register(o,a,a);return o},_=(e,t,r)=>this.wasm.closure9_externref_shim(e,t,r);return{wbg:{__wbg_addEventListener_775911544ac9d643:(e,t,r,i)=>this.canvasListeners[this.getStringFromWasm(t,r)]=i,__wbg_appendChild_87a6cc0aeb132c06:()=>{},__wbg_axes_57e916a6e0ffb3e4:()=>{},__wbg_body_8822ca55cb3730d2:()=>this.addToExternrefTable(null),__wbg_call_13410aac570ffff7:()=>{},__wbg_createElement_4909dfa2011f2abe:()=>this.mockElement,__wbg_document_7d29d139bd619045:()=>this.addToExternrefTable({}),__wbg_from_88bc52ce20ba6318:(...e)=>Array.from(e[0]),__wbg_getGamepads_c373aed0f1e5e4a6:(...e)=>e[0].getGamepads(),__wbg_get_458e874b43b18b25:(...e)=>Reflect.get(e[0],e[1]),__wbg_get_0da715ceaecea5c8:(...e)=>e[0][e[1]>>>0],__wbg_has_b89e451f638123e3:()=>!0,__wbg_instanceof_Gamepad_2987f05b50f4775a:()=>!0,__wbg_instanceof_Window_12d20d558ef92592:()=>!0,__wbg_isTrusted_04e871d8dde8ea8a:()=>!0,__wbg_length_186546c51cd61acd:(...e)=>e[0].length,__wbg_movementX_0ef0e79f7b9168fc:(...e)=>e[0].movementX,__wbg_movementY_875c2fc2aabd99bf:(...e)=>e[0].movementY,__wbg_navigator_65d5ad763926b868:(...e)=>e[0].navigator,__wbg_new_19c25a3f2fa63a02:()=>({}),__wbg_newnoargs_254190557c45b4ec:()=>{},__wbg_now_1e80617bcee43265:()=>this.processDate||Date.now(),__wbg_set_453345bcda80b89a:(...e)=>Reflect.set(e[0],e[1],e[2]),__wbg_settextContent_b55fe2f5f1399466:async(...e)=>{this.mockElement.textContent=this.getStringFromWasm(e[1],e[2]);this.processListeners.forEach((t)=>t(this.mockElement.textContent))},__wbg_static_accessor_GLOBAL_8921f820c2ce3f12:()=>{},__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184:()=>{},__wbg_static_accessor_SELF_995b214ae681ff99:()=>this.addToExternrefTable({}),__wbg_static_accessor_WINDOW_cde3890479c675ea:()=>{},__wbg_wbindgenbooleanget_3fe6f642c7d97746:(e)=>{if(typeof e==="boolean")return e?1:0;return null},__wbg_wbindgendebugstring_99ef257a3ddda34d:(e,t)=>{const r=this.getStringFromWasm(e,t),[i,a]=this.passStringToWasm(r),o=new DataView(this.wasm.memory.buffer);o.setInt32(e+4,a,!0);o.setInt32(e+0,i,!0)},__wbg_wbindgenisnull_f3037694abe4d97a:(e)=>e===null?1:0,__wbg_wbindgenisundefined_c4b71d073b92f3c5:(e)=>typeof e>"u"?1:0,__wbg_wbindgennumberget_f74b4c7525ac05cb:(e,t)=>{const r=t,i=typeof r==="number"?r:null,a=new DataView(this.wasm.memory.buffer);a.setFloat64(e+8,i,!0);a.setInt32(e+0,1,!0)},__wbg_wbindgenthrow_451ec1a8469d7eb6:(e,t)=>this.debug&&console.log("call 31",e,t),__wbindgen_cast_01559742fdcca8af:(e,t)=>s(e,t,8,_),__wbindgen_cast_2241b6af4c4b2941:(e,t)=>this.getStringFromWasm(e,t),__wbindgen_cast_2495c10526b24646:(e,t)=>s(e,t,8,_),__wbindgen_cast_d6cd19b81560fd6e:(e)=>e,__wbindgen_init_externref_table:()=>{const e=this.wasm.__wbindgen_export_2,t=e.grow(4);e.set(0,null);e.set(t+0,null);e.set(t+1,null);e.set(t+2,!0);e.set(t+3,!1)}}}}async process(n,s){if(s)this.processDate=s;const _=new Promise((r)=>this.processListeners.push(r)),[e,t]=this.passStringToWasm(n);this.wasm.process(e,t);return _}validate(n){let s,_;try{const[e,t]=this.passStringToWasm(n),r=this.wasm.validate(e,t);s=r[0];_=r[1];return this.getStringFromWasm(s,_)}finally{this.wasm.__wbindgen_free(s,_,1)}}getYawPitch=()=>this.wasm.get_yaw_pitch();resetYawPitch=()=>this.wasm.reset_yaw_pitch();coords(n,s){this.wasm.reset_yaw_pitch();const _=this.wasm.get_yaw_pitch(),{movementX:e,movementY:t}=m(_.yaw,_.pitch,n,s);this.canvasListeners.pointermove({movementX:e,movementY:t});return this.wasm.get_yaw_pitch().coords}}export default WASM;
1
+ import { wasmBytes } from "./bytes.js";
2
+ import { calculateMovements } from "./util.js";
3
+
4
+ export class WASM {
5
+ wasm;
6
+ debug = false;
7
+ canvasListeners = {};
8
+ mockElement = { textContent: "" };
9
+ processDate = null;
10
+ processListeners = [];
11
+ async initWasm() {
12
+ const wasmInstantiated = await WebAssembly.instantiate(wasmBytes, this.getImports());
13
+ this.wasm = wasmInstantiated.instance.exports;
14
+ this.wasm.start();
15
+ const [ptr, len] = this.passStringToWasm([...Array(14)].map(() => Math.random().toString(36)[2]).join(""));
16
+ this.wasm.set_mouse_params(50, 1, 1, false, ptr, len);
17
+ const movementX = Math.floor(Math.random() * 10) + 1;
18
+ const movementY = Math.floor(Math.random() * 10) + 1;
19
+ this.canvasListeners.pointermove({ movementX, movementY });
20
+ }
21
+ getStringFromWasm = (ptr, len) => {
22
+ if (!this.wasm)
23
+ return "";
24
+ ptr >>>= 0;
25
+ return new TextDecoder().decode(new Uint8Array(this.wasm.memory.buffer).subarray(ptr, ptr + len));
26
+ };
27
+ passStringToWasm = (str) => {
28
+ if (!this.wasm)
29
+ return;
30
+ const buf = new TextEncoder().encode(str);
31
+ const ptr = this.wasm.__wbindgen_malloc(buf.length, 1) >>> 0;
32
+ new Uint8Array(this.wasm.memory.buffer).subarray(ptr, ptr + buf.length).set(buf);
33
+ return [ptr, buf.length];
34
+ };
35
+ addToExternrefTable = (obj) => {
36
+ if (!this.wasm)
37
+ return;
38
+ const idx = this.wasm.__externref_table_alloc();
39
+ this.wasm.__wbindgen_export_2.set(idx, obj);
40
+ return idx;
41
+ };
42
+ getImports() {
43
+ const CLOSURE_DTORS = new FinalizationRegistry((state) => {
44
+ this.wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b);
45
+ });
46
+ const makeMutClosure = (arg0, arg1, dtor, f) => {
47
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
48
+ const real = (...args) => {
49
+ state.cnt++;
50
+ const a = state.a;
51
+ state.a = 0;
52
+ try {
53
+ return f(a, state.b, ...args);
54
+ } finally {
55
+ if (--state.cnt === 0) {
56
+ this.wasm.__wbindgen_export_5.get(state.dtor)(a, state.b);
57
+ CLOSURE_DTORS.unregister(state);
58
+ } else
59
+ state.a = a;
60
+ }
61
+ };
62
+ real.original = state;
63
+ CLOSURE_DTORS.register(real, state, state);
64
+ return real;
65
+ };
66
+ const __wbg_adapter_6 = (arg0, arg1, arg2) => this.wasm.closure9_externref_shim(arg0, arg1, arg2);
67
+ return {
68
+ wbg: {
69
+ __wbg_addEventListener_775911544ac9d643: (_t, arg1, arg2, callback) => this.canvasListeners[this.getStringFromWasm(arg1, arg2)] = callback,
70
+ __wbg_appendChild_87a6cc0aeb132c06: () => {},
71
+ __wbg_axes_57e916a6e0ffb3e4: () => {},
72
+ __wbg_body_8822ca55cb3730d2: () => this.addToExternrefTable(null),
73
+ __wbg_call_13410aac570ffff7: () => {},
74
+ __wbg_createElement_4909dfa2011f2abe: () => this.mockElement,
75
+ __wbg_document_7d29d139bd619045: () => this.addToExternrefTable({}),
76
+ __wbg_from_88bc52ce20ba6318: (...args) => Array.from(args[0]),
77
+ __wbg_getGamepads_c373aed0f1e5e4a6: (...args) => args[0].getGamepads(),
78
+ __wbg_get_458e874b43b18b25: (...args) => Reflect.get(args[0], args[1]),
79
+ __wbg_get_0da715ceaecea5c8: (...args) => args[0][args[1] >>> 0],
80
+ __wbg_has_b89e451f638123e3: () => true,
81
+ __wbg_instanceof_Gamepad_2987f05b50f4775a: () => true,
82
+ __wbg_instanceof_Window_12d20d558ef92592: () => true,
83
+ __wbg_isTrusted_04e871d8dde8ea8a: () => true,
84
+ __wbg_length_186546c51cd61acd: (...args) => args[0].length,
85
+ __wbg_movementX_0ef0e79f7b9168fc: (...args) => args[0].movementX,
86
+ __wbg_movementY_875c2fc2aabd99bf: (...args) => args[0].movementY,
87
+ __wbg_navigator_65d5ad763926b868: (...args) => args[0].navigator,
88
+ __wbg_new_19c25a3f2fa63a02: () => new Object,
89
+ __wbg_newnoargs_254190557c45b4ec: () => {},
90
+ __wbg_now_1e80617bcee43265: () => this.processDate || Date.now(),
91
+ __wbg_set_453345bcda80b89a: (...args) => Reflect.set(args[0], args[1], args[2]),
92
+ __wbg_settextContent_b55fe2f5f1399466: async (...args) => {
93
+ this.mockElement.textContent = this.getStringFromWasm(args[1], args[2]);
94
+ this.processListeners.forEach((listener) => listener(this.mockElement.textContent));
95
+ },
96
+ __wbg_static_accessor_GLOBAL_8921f820c2ce3f12: () => {},
97
+ __wbg_static_accessor_GLOBAL_THIS_f0a4409105898184: () => {},
98
+ __wbg_static_accessor_SELF_995b214ae681ff99: () => this.addToExternrefTable({}),
99
+ __wbg_static_accessor_WINDOW_cde3890479c675ea: () => {},
100
+ __wbg_wbindgenbooleanget_3fe6f642c7d97746: (arg0) => {
101
+ if (typeof arg0 === "boolean")
102
+ return arg0 ? 1 : 0;
103
+ return null;
104
+ },
105
+ __wbg_wbindgendebugstring_99ef257a3ddda34d: (arg0, arg1) => {
106
+ const str = this.getStringFromWasm(arg0, arg1);
107
+ const [ptr, len] = this.passStringToWasm(str);
108
+ const dv = new DataView(this.wasm.memory.buffer);
109
+ dv.setInt32(arg0 + 4 * 1, len, true);
110
+ dv.setInt32(arg0 + 4 * 0, ptr, true);
111
+ },
112
+ __wbg_wbindgenisnull_f3037694abe4d97a: (arg0) => arg0 === null ? 1 : 0,
113
+ __wbg_wbindgenisundefined_c4b71d073b92f3c5: (arg0) => typeof arg0 === "undefined" ? 1 : 0,
114
+ __wbg_wbindgennumberget_f74b4c7525ac05cb: (arg0, arg1) => {
115
+ const obj = arg1;
116
+ const ret = typeof obj === "number" ? obj : null;
117
+ const dv = new DataView(this.wasm.memory.buffer);
118
+ dv.setFloat64(arg0 + 8 * 1, ret, true);
119
+ dv.setInt32(arg0 + 4 * 0, 1, true);
120
+ },
121
+ __wbg_wbindgenthrow_451ec1a8469d7eb6: (a, b) => this.debug && console.log("call 31", a, b),
122
+ __wbindgen_cast_01559742fdcca8af: (arg0, arg1) => makeMutClosure(arg0, arg1, 8, __wbg_adapter_6),
123
+ __wbindgen_cast_2241b6af4c4b2941: (arg0, arg1) => this.getStringFromWasm(arg0, arg1),
124
+ __wbindgen_cast_2495c10526b24646: (arg0, arg1) => makeMutClosure(arg0, arg1, 8, __wbg_adapter_6),
125
+ __wbindgen_cast_d6cd19b81560fd6e: (arg0) => arg0,
126
+ __wbindgen_init_externref_table: () => {
127
+ const table = this.wasm.__wbindgen_export_2;
128
+ const offset = table.grow(4);
129
+ table.set(0, null);
130
+ table.set(offset + 0, null);
131
+ table.set(offset + 1, null);
132
+ table.set(offset + 2, true);
133
+ table.set(offset + 3, false);
134
+ }
135
+ }
136
+ };
137
+ }
138
+ async process(str, date) {
139
+ if (date)
140
+ this.processDate = date;
141
+ const promise = new Promise((resolve) => this.processListeners.push(resolve));
142
+ const [ptr, len] = this.passStringToWasm(str);
143
+ this.wasm.process(ptr, len);
144
+ return promise;
145
+ }
146
+ validate(input) {
147
+ let retPtr;
148
+ let retLen;
149
+ try {
150
+ const [ptr, len] = this.passStringToWasm(input);
151
+ const ret = this.wasm.validate(ptr, len);
152
+ retPtr = ret[0];
153
+ retLen = ret[1];
154
+ return this.getStringFromWasm(retPtr, retLen);
155
+ } finally {
156
+ this.wasm.__wbindgen_free(retPtr, retLen, 1);
157
+ }
158
+ }
159
+ getYawPitch = () => this.wasm.get_yaw_pitch();
160
+ resetYawPitch = () => this.wasm.reset_yaw_pitch();
161
+ coords(yaw, pitch) {
162
+ this.wasm.reset_yaw_pitch();
163
+ const currentYP = this.wasm.get_yaw_pitch();
164
+ const { movementX, movementY } = calculateMovements(currentYP.yaw, currentYP.pitch, yaw, pitch);
165
+ this.canvasListeners.pointermove({ movementX, movementY });
166
+ const newYawPitch = this.wasm.get_yaw_pitch();
167
+ return newYawPitch.coords;
168
+ }
169
+ }
170
+ export default WASM;
package/dist/wasm/util.js CHANGED
@@ -1 +1,19 @@
1
- export const sensitivity=0.0025,normalizeYaw=(t)=>{while(t<0)t+=2*Math.PI;while(t>=2*Math.PI)t-=2*Math.PI;return t},calculateMovements=(t,n,o,a)=>{const i=normalizeYaw(t);let e=normalizeYaw(o)-i;if(Math.abs(e)>Math.PI)e=e>0?e-2*Math.PI:e+2*Math.PI;const r=a-n,s=Math.round(-e/0.0025),h=Math.round(-r/0.0025);return{movementX:s,movementY:h}};
1
+ export const sensitivity = 0.0025;
2
+ export const normalizeYaw = (yaw) => {
3
+ while (yaw < 0)
4
+ yaw += 2 * Math.PI;
5
+ while (yaw >= 2 * Math.PI)
6
+ yaw -= 2 * Math.PI;
7
+ return yaw;
8
+ };
9
+ export const calculateMovements = (currentYaw, currentPitch, targetYaw, targetPitch) => {
10
+ const normalizedCurrentYaw = normalizeYaw(currentYaw);
11
+ const normalizedTargetYaw = normalizeYaw(targetYaw);
12
+ let yawDiff = normalizedTargetYaw - normalizedCurrentYaw;
13
+ if (Math.abs(yawDiff) > Math.PI)
14
+ yawDiff = yawDiff > 0 ? yawDiff - 2 * Math.PI : yawDiff + 2 * Math.PI;
15
+ const pitchDiff = targetPitch - currentPitch;
16
+ const movementX = Math.round(-yawDiff / sensitivity);
17
+ const movementY = Math.round(-pitchDiff / sensitivity);
18
+ return { movementX, movementY };
19
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers bot in under 10 lines.",
4
- "version": "1.4.4",
4
+ "version": "1.4.6",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
@@ -30,106 +30,106 @@
30
30
  ".": "./dist/index.js",
31
31
  "./api": {
32
32
  "import": "./dist/api.js",
33
- "types": "./dist/types/api.d.ts"
33
+ "types": "./dist/api.d.ts"
34
34
  },
35
35
  "./browser": "./browser/build/module.js",
36
36
  "./browser/*": "./browser/build/*.js",
37
37
  "./browser/*.js": "./browser/build/*.js",
38
38
  "./comm": {
39
39
  "import": "./dist/comm/index.js",
40
- "types": "./dist/types/comm/index.d.ts"
40
+ "types": "./dist/comm/index.d.ts"
41
41
  },
42
42
  "./matchmaker": {
43
43
  "import": "./dist/matchmaker.js",
44
- "types": "./dist/types/matchmaker.d.ts"
44
+ "types": "./dist/matchmaker.d.ts"
45
45
  },
46
46
  "./util": {
47
47
  "import": "./dist/util.js",
48
- "types": "./dist/types/util.d.ts"
48
+ "types": "./dist/util.d.ts"
49
49
  },
50
50
  "./pathing/*": "./dist/pathing/*.js",
51
51
  "./pathing/*.js": "./dist/pathing/*.js",
52
52
  "./bot": {
53
53
  "import": "./dist/bot.js",
54
- "types": "./dist/types/bot.d.ts"
54
+ "types": "./dist/bot.d.ts"
55
55
  },
56
56
  "./bot/*": {
57
57
  "import": "./dist/bot/*.js",
58
- "types": "./dist/types/bot/*.d.ts"
58
+ "types": "./dist/bot/*.d.ts"
59
59
  },
60
60
  "./bot/*.js": {
61
61
  "import": "./dist/bot/*.js",
62
- "types": "./dist/types/bot/*.d.ts"
62
+ "types": "./dist/bot/*.d.ts"
63
63
  },
64
64
  "./constants": {
65
65
  "import": "./dist/constants/index.js",
66
- "types": "./dist/types/constants/index.d.ts"
66
+ "types": "./dist/constants/index.d.ts"
67
67
  },
68
68
  "./constants/*": {
69
69
  "import": "./dist/constants/*.js",
70
- "types": "./dist/types/constants/*.d.ts"
70
+ "types": "./dist/constants/*.d.ts"
71
71
  },
72
72
  "./constants/*.js": {
73
73
  "import": "./dist/constants/*.js",
74
- "types": "./dist/types/constants/*.d.ts"
74
+ "types": "./dist/constants/*.d.ts"
75
75
  },
76
76
  "./dispatch": {
77
77
  "import": "./dist/dispatches/index.js",
78
- "types": "./dist/types/dispatches.d.ts"
78
+ "types": "./dist/dispatches.d.ts"
79
79
  },
80
80
  "./dispatch/*": {
81
81
  "import": "./dist/dispatches/*.js",
82
- "types": "./dist/types/dispatches/*.d.ts"
82
+ "types": "./dist/dispatches/*.d.ts"
83
83
  },
84
84
  "./dispatch/*.js": {
85
85
  "import": "./dist/dispatches/*.js",
86
- "types": "./dist/types/dispatches/*.d.ts"
86
+ "types": "./dist/dispatches/*.d.ts"
87
87
  },
88
88
  "./dispatches": {
89
89
  "import": "./dist/dispatches/index.js",
90
- "types": "./dist/types/dispatches.d.ts"
90
+ "types": "./dist/dispatches.d.ts"
91
91
  },
92
92
  "./dispatches/*": {
93
93
  "import": "./dist/dispatches/*.js",
94
- "types": "./dist/types/dispatches/*.d.ts"
94
+ "types": "./dist/dispatches/*.d.ts"
95
95
  },
96
96
  "./dispatches/*.js": {
97
97
  "import": "./dist/dispatches/*.js",
98
- "types": "./dist/types/dispatches/*.d.ts"
98
+ "types": "./dist/dispatches/*.d.ts"
99
99
  },
100
100
  "./socket": {
101
101
  "import": "./dist/socket.js",
102
- "types": "./dist/types/socket.d.ts"
102
+ "types": "./dist/socket.d.ts"
103
103
  },
104
104
  "./wasm": {
105
105
  "import": "./dist/wasm/direct.js",
106
- "types": "./dist/types/wasm/direct.d.ts"
106
+ "types": "./dist/wasm/direct.d.ts"
107
107
  },
108
108
  "./wasm/*": {
109
109
  "import": "./dist/wasm/*.js",
110
- "types": "./dist/types/wasm/*.d.ts"
110
+ "types": "./dist/wasm/*.d.ts"
111
111
  },
112
112
  "./wasm/*.js": {
113
113
  "import": "./dist/wasm/*.js",
114
- "types": "./dist/types/wasm/*.d.ts"
114
+ "types": "./dist/wasm/*.d.ts"
115
115
  }
116
116
  },
117
117
  "typesVersions": {
118
118
  "*": {
119
- "api": ["dist/types/api.d.ts"],
120
- "comm": ["dist/types/comm/index.d.ts"],
121
- "matchmaker": ["dist/types/matchmaker.d.ts"],
122
- "util": ["dist/types/util.d.ts"],
123
- "bot": ["dist/types/bot/*.d.ts"],
124
- "bot/*": ["dist/types/bot/*.d.ts"],
125
- "constants": ["dist/types/constants/*.d.ts"],
126
- "constants/*": ["dist/types/constants/*.d.ts"],
127
- "dispatch": ["dist/types/dispatches.d.ts"],
128
- "dispatch/*": ["dist/types/dispatches/*.d.ts"],
129
- "dispatches": ["dist/types/dispatches.d.ts"],
130
- "dispatches/*": ["dist/types/dispatches/*.d.ts"],
131
- "wasm": ["dist/types/wasm/direct.d.ts"],
132
- "wasm/*": ["dist/types/wasm/*.d.ts"]
119
+ "api": ["dist/api.d.ts"],
120
+ "comm": ["dist/comm/index.d.ts"],
121
+ "matchmaker": ["dist/matchmaker.d.ts"],
122
+ "util": ["dist/util.d.ts"],
123
+ "bot": ["dist/bot/*.d.ts"],
124
+ "bot/*": ["dist/bot/*.d.ts"],
125
+ "constants": ["dist/constants/*.d.ts"],
126
+ "constants/*": ["dist/constants/*.d.ts"],
127
+ "dispatch": ["dist/dispatches.d.ts"],
128
+ "dispatch/*": ["dist/dispatches/*.d.ts"],
129
+ "dispatches": ["dist/dispatches.d.ts"],
130
+ "dispatches/*": ["dist/dispatches/*.d.ts"],
131
+ "wasm": ["dist/wasm/direct.d.ts"],
132
+ "wasm/*": ["dist/wasm/*.d.ts"]
133
133
  }
134
134
  },
135
135
  "dependencies": {
@@ -137,11 +137,10 @@
137
137
  },
138
138
  "devDependencies": {
139
139
  "@stylistic/eslint-plugin": "^4.4.1",
140
- "@types/bun": "^1.3.3",
141
- "eslint": "^9.39.1"
140
+ "@types/bun": "^1.3.5",
141
+ "eslint": "^9.39.2"
142
142
  },
143
143
  "scripts": {
144
- "lint": "bunx --bun eslint . --fix",
145
- "b": "bun cli/build"
144
+ "lint": "bunx --bun eslint . --fix"
146
145
  }
147
146
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes