-
Notifications
You must be signed in to change notification settings - Fork 12
/
preferences.html
492 lines (492 loc) · 22.2 KB
/
preferences.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FPS Preferences</title>
<style>
body {
background: #444;
font-family: Arial, Helvetica, sans-serif;
width: 100vw;
overflow: hidden !important;
}
.weapon {
position: relative;
box-shadow: 0 5px 10px #25750a;
cursor: pointer;
transition: transform 1s, box-shadow 1s;
background: #333;
width: 50%;
}
.weapon:hover:not(.focus) {
transform: scale(1.1);
box-shadow: 0 0 #000;
z-index: 100;
}
.focus {
transform: scale(1.1);
box-shadow: 0 0 0 5px #fff;
}
.weapon:hover + .center {
z-index: 101;
}
.holder {
position: relative;
display: inline-block;
text-align: center;
left: 0;
margin: 10px;
margin-right: 2.5%;
margin-left: -10px;
}
.center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
color: #fff;
font-size: 30px;
font-weight: 600;
}
.container {
position: relative;
left: 50%;
width: 1500px;
margin-left: -650px;
top: 0;
}
h1 {
position: relative;
font-size: 50px;
color: #333;
text-align: center;
text-shadow: 2px 2px #25750a;
}
iframe {
position: absolute;
width: 75%;
height: 100%;
margin: 0;
border: none;
outline: none;
z-index: 100;
}
canvas {
position: absolute;
top: -50px !important;
left: 35% !important;
width: 100% !important;
transform: scale(1) !important;
z-index: -100;
pointer-events: none !important;
}
.swal-modal {
background: #444;
box-shadow: 0px 0px 10px 5px #ff4444;
}
.swal-modal * {
color: #ff4444;
}
.swal-button {
background: #ff4444 !important;
color: #333 !important;
box-shadow: none !important;
outline: none !important;
}
* {
z-index: 9999 !important;
}
footer {
position: absolute;
width: 100%;
height: 25px;
padding: 5px;
left: 0;
right: 0;
bottom: 0;
background: #25750a;
}
button {
background: #333;
border: none !important;
border-radius: 0;
color: #25750a;
padding: 5px;
border-bottom-left-radius: 12px;
}
textarea {
background: #333;
border: none;
outline: 2px solid #ff4444;
width: 100%;
height: 200px;
resize: none !important;
white-space: pre-wrap;
padding-left: 0;
}
.keyinput {
width: 20px;
background: #333;
border: none !important;
outline: none !important;
align-items: right;
}
</style>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/EastDesire/jscolor@latest/jscolor.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2ZQ6TMGVXJ"></script>
<script>
window.dataLayer=window.dataLayer||[];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "G-2ZQ6TMGVXJ");
</script>
<body>
<button onclick="history.go(-1)" align="left" style="position:absolute;left:40px;top:30px;margin:0;transform:scale(1.2);z-index:999999!important">< Back</button>
<script src="https://parking-master.github.io/FPS3/js/three.min.js"></script>
<script src="https://fps3.uk.to/js/GLTFLoader.min.js"></script>
<script src="https://fps3.uk.to/js/fflate.min.js"></script>
<audio id="walking" src="sounds/walking.mp3" loop volume=".5"></audio>
<audio id="gunsound-rifle" src="sounds/guns/default_rifle.mp3"></audio>
<iframe src="loadout.html" allow-transparency="true" style="background:transparent!important"></iframe>
<input id="color-value" value="#fff" type="text" data-jscolor="{}" style="position:absolute;z-index:99999;cursor:pointer;left:80%;width:170px;border:none">
<select id="type-value" value="Mark VI" type="drop" style="position:absolute;z-index:99999;cursor:pointer;left:80%;margin-top:25px;width:212px;background:#fff;border:none" onchange="changeCharacter(this.value)">
<option id="Mark VI">Mark VI</option>
<option id="FOTUS">FOTUS</option>
</select>
<footer>
<button onclick="performance(false)">Performance</button>
<button onclick="bot()">Custom Bot</button>
<button onclick="fire(3)" align="right">Fire (F)</button>
<button onclick="walk()" align="right">Walk (W)</button>
<button onclick="stopWalk()" align="right">Stop Walk (W+)</button>
<button onclick="keyCustomize()" align="right">Custom Key Events</button>
</footer>
<script>
performance.now = Date.now;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, .1 ,1000);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(2);
document.body.appendChild(renderer.domElement);
scene.add(camera);
function performance(redirect) {
let container = document.createElement("div");
let slider = document.createElement("input");
let sliderAmount = document.createElement("span");
container.appendChild(slider);
container.appendChild(sliderAmount);
slider.type = "range";
slider.value = localStorage["performance"] || 100;
let g = setInterval(() => { sliderAmount.textContent = (((slider.value-0)+250)*7.5).toFixed(0) + " MB" }, 100);
swal({
title: "Performance",
text: "Set the amount of performance the game takes.",
content: container,
closeOnEsc: false,
closeOnEnterKey: false,
closeOnSpaceKey: false,
closeOnClickOutside: false
}).then((e) => {
clearInterval(g);
localStorage.setItem("performance", document.querySelector(".swal-content").querySelector("input").value);
redirect ? location.replace(decodeURIComponent(atob(new URLSearchParams(location.search).get("r")))+"#ignore") : swal.close();
});
}
botFunctions = {
"script": function() {
let box = document.createElement("textarea");
box.value = `
// bot's character model: \`otherPlayer\`
let deathCooldown = false;
start();
otherPlayer.position.set(0, -1, 46);
otherPlayer.rotation.set(0, 0, 0);
gametime.on("endPlayerWalk", function(player) {});
gametime.run("syncCountdown", [gametime.user.position==1?2:1]);
otherPlayer.maxshot = 6;
let sync = setInterval(() => {
if (didStart) {
let wr = true;
let wo = true;
let wi = true;
let dw = true;
setInterval(() => {
dw&&(()=>{let b = mixer1.clipAction(characterAnimations[0]);b.play(),dw=false})();
otherPlayer.translateZ(-.03);
wr&&otherPlayer.translateY(.002);
wo&&otherPlayer.rotateY(.01);
wi&&otherPlayer.rotateY(-.02);
}, 60);
setTimeout(() => { wr = false }, 7500);
setTimeout(() => { wo = false }, 2000);
setTimeout(() => { wi = false }, 1000);
setTimeout(() => { setInterval(() => { otherPlayer.lookAt(camera.position), otherPlayer.rotateY(Math.PI), (deathCooldown||(distanceTo(otherPlayer.position,camera.position)<=20&&(document.body.appendChild(gunsounds.pistol.cloneNode()).play(),(Math.floor(Math.random()*2)==1&&((e)=>{for(let i=0;i<e;i++){gametime.run("hit",[gametime.user.position])}})(5))))) }, 500) }, 8000);
let cd;
setInterval(()=>{otherPlayer.position.y=defaultY},1000);
gametime.on("hit", function(player) {
cd = true;
if (!cd) {
return;
}
if (player != gametime.user.position) {
if (otherPlayer.maxshot <= 0) {
cd && (gametime.run("eleminate", [gametime.user.position==1?2:1]), cd = false, setTimeout(() => { cd = true }, 1000));
return;
}
otherPlayer.maxshot--;
return;
}
health += -1;
clearTimeout(healthUpgradeTimeout);
healthUpgradeTimeout = setTimeout(() => { health = 100 }, 5000);
if (health <= 0) {
gametime.run("eleminate", [gametime.user.position]);
}
if (health <= 50) {
document.querySelector(".health-wrapper").style.boxShadow = "0px 0px 10px 7px #ff4444";
} else {
document.querySelector(".health-wrapper").style.boxShadow = "0px 0px 10px 7px #25750a";
}
document.querySelector(".health").style.width = health + "%";
let n = setInterval(() => {
if (document.querySelector("#hiteffect").style.opacity >= 1) {
return clearInterval(n), (() => {
let n = setInterval(() => {
if (document.querySelector("#hiteffect").style.opacity <= 0) {
return clearInterval(n);
}
document.querySelector("#hiteffect").style.opacity = String((document.querySelector("#hiteffect").style.opacity-0) - .1);
});
})();
}
document.querySelector("#hiteffect").style.opacity = String((document.querySelector("#hiteffect").style.opacity-0) + .1);
});
});
let r = false;
gametime.on("eleminate", function(player) {
setTimeout(() => { r = false }, 1000);
let q = Math.floor(Math.random()*2);
document.querySelector("#death3").play();
if (player != gametime.user.position) {
!r && (score1++, r=true);
GameOver();
scene.remove(otherPlayer);
switchToDeath(otherPlayer);
otherPlayer.position.set((q==1?-20:20), 0, 20);
otherPlayer.rotation.set(0, (q==1?-Math.PI/2+.5:Math.PI/2-.5), 0);
setTimeout(() => { scene.add(otherPlayer) }, 2000);
return;
}
!r && (score2++, r=true);
GameOver();
otherPlayer.position.set(q==1?-20:20, 0, 20);
otherPlayer.rotation.set(0, q==1?-Math.PI/2+.5:Math.PI/2-.5, 0);
otherPlayer.maxshot = 6;
deathCooldown = true;
setTimeout(() => {
deathCooldown = false;
}, 10000);
switchToDeath(camera);
let t = 5;
let spawnPoint = (distanceTo({x:respawnPoints[0][0],y:respawnPoints[0][1],z:respawnPoints[0][2]},otherPlayer.position)<=20)?respawnPoints[1]:respawnPoints[0];
swal({
title: "You died!",
text: "You will respawn in " + t + " seconds...",
closeOnEsc: false,
closeOnEnterKey: false,
closeOnSpaceKey: false,
closeOnClickOutside: false,
button: false
});
walkAxisYLocked = false;
camera.position.set(0,30,0);
camera.rotation.set(-Math.PI/2,0,Math.PI/2);
controls.isLocked = false;
scene.remove(gun);
scene.remove(myPlayer);
document.querySelector(".ui").style.visibility = "hidden";
let i = setInterval(() => {
t <= 0 ? (clearInterval(i), respawn(spawnPoint), gametime.run("respawn", [gametime.user.position + "," + spawnPoint.join(",")])) : t--;
document.querySelector(".swal-text").textContent = "You will respawn in " + t + " seconds...";
}, 1000);
});
clearInterval(sync);
}
});
`;
swal({
text: "Custom JavaScript code that your bot uses",
content: box,
buttons: ["Save"]
});
}
};
function bot() {
let container = document.createElement("div");
container.innerHTML = `
<button onclick="botFunctions['script']()">Custom script</button>
<button onclick="botFunctions['appearance']()">Bot Appearance</button>
<button onclick="botFunctions['difficulty']()">Bot difficulty</button>
<button onclick="botFunctions['invetory']()">Bot invetory</button>
`;
let g = setInterval(() => { sliderAmount.textContent = (((slider.value-0)+250)*7.5).toFixed(0) + " MB" }, 100);
swal({
title: "Customize bot",
text: "Customize everything about your bot",
content: container,
closeOnEsc: false,
closeOnEnterKey: false,
closeOnSpaceKey: false,
closeOnClickOutside: false
}).then((e) => {
clearInterval(g);
localStorage.setItem("performance", document.querySelector(".swal-content").querySelector("input").value);
redirect ? location.replace(decodeURIComponent(atob(new URLSearchParams(location.search).get("r")))+"#ignore") : swal.close();
});
}
keyDefs = {
"shoot": 0,
"punch": 1,
"reload": 2,
"jump": 3,
"interact": 4,
"throwGrenade": 5,
"switchWeapon": 6,
"zoomIn": 7,
"zoomOut": 8
};
function saveKey(type, key) {
let localKey = (localStorage["prefsKeyControls"] || "f,b,r, ,t,m,y,i,z,p").split(",");
localKey[keyDefs[type]] = key;
console.log(localKey);
localStorage.setItem("prefsKeyControls", localKey.join(","));
}
function keyCustomize() {
let container = document.createElement("div");
container.innerHTML = `
<h3>Functional Keys</h3>
<label for="shoot">Shoot: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('shoot',this.value)" class="keyinput" name="shoot" value="f"><br>
<label for="punch">Punch: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('punch',this.value)" class="keyinput" name="punch" value="b"><br>
<label for="reload">Reload: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('reload',this.value)" class="keyinput" name="reload" value="r"><br>
<label for="switchWeapon">Switch Weapon: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('switchWeapon',this.value)" class="keyinput" name="switchWeapon" value="y"><br>
<label for="zoomIn">Zoom In: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('zoomIn',this.value)" class="keyinput" name="zoomIn" value="i"><br>
<label for="zoomOut">Zoom Out: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('zoomOut',this.value)" class="keyinput" name="zoomOut" value="z"><br>
<label for="throwGrenade">Throw Grenade: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('throwGrenade',this.value)" class="keyinput" name="throwGrenade" value="m"><br>
<label for="interact">Interact: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('interact',this.value)" class="keyinput" name="interact" value="t"><br>
<h3>Navigational Keys</h3>
<label for="jump">Jump: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('jump',this.value)" class="keyinput" name="jump" value=" "><br>
<h3>Menu Keys</h3>
<label for="pause">Pause: </label><input onkeyup="this.value=(this.value==' '?' ':this.value[0]||''),event.key=='Enter'&&saveKey('pause',this.value)" class="keyinput" name="pause" value="p"><br>
`;
swal({
title: "Customize keys",
content: container,
buttons: ["Cancel", "Save"],
closeOnEsc: false,
closeOnEnterKey: false,
closeOnSpaceKey: false,
closeOnClickOutside: false
}).then((e) => {
if (e) {
for (let i = 0; i < document.querySelectorAll(".keyinput").length; i++) {
saveKey(document.querySelectorAll(".keyinput")[i].name, document.querySelectorAll(".keyinput")[i].value);
}
}
});
}
window.onload = () => {
if (location.hash == "#memory") {
performance(true);
}
};
isw = false;
clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
typeof character != "undefined" && changeColor(document.querySelector("#color-value").value);
typeof character != "undefined" && (character.rotation.y += .003);
let delta = clock.getDelta();
if (typeof mixer != "undefined") mixer.update(delta+.02);
renderer.render(scene, camera);
}
light = new THREE.DirectionalLight(0xffffff, 4), light.position.set(10,20,10), scene.add(light);
(new THREE.GLTFLoader).load("models/characters/"+(localStorage["character"]||"mark-vi")+".glb", (e) => {
character = e.scene;
scene.add(character);
character.position.copy(camera.position),character.rotation.copy(camera.rotation),character.updateMatrix(),character.translateZ(-5);
character.rotation.set(0,Math.PI,0),camera.rotation.set(0,0,0),character.position.set(0,0,0),camera.position.set(0,2,3);
mixer = new THREE.AnimationMixer(character);
characterAnimations = e.animations;
});
animate();
document.querySelector("canvas").addEventListener("mousemove", (e) => {
character.rotation.y = (e.clientX/400);
});
document.querySelector("#color-value").value = localStorage["prefsArmorColor"] || "#ffffff";
function changeColor(value) {
localStorage.setItem("prefsArmorColor", value);
character.getObjectByName("Object_7").material.color.setRGB(new THREE.Color(localStorage["prefsArmorColor"]).r,new THREE.Color(localStorage["prefsArmorColor"]).g,new THREE.Color(localStorage["prefsArmorColor"]).b);
(localStorage["character"]=="fotus"?character.getObjectByName("fotus_helmet_masterstl"):character.getObjectByName("Object_10")).material.color.setRGB(new THREE.Color(localStorage["prefsArmorColor"]).r,new THREE.Color(localStorage["prefsArmorColor"]).g,new THREE.Color(localStorage["prefsArmorColor"]).b);
}
function changeCharacter(value) {
localStorage["character"] = value.toLowerCase().replace(/ /gi, "-");
stopWalk();
(new THREE.GLTFLoader).load("models/characters/"+(localStorage["character"]||"mark-vi")+".glb", (e) => {
scene.remove(character);
character = e.scene;
scene.add(character);
character.position.copy(camera.position),character.rotation.copy(camera.rotation),character.updateMatrix(),character.translateZ(-5);
character.rotation.set(0,Math.PI,0),camera.rotation.set(0,0,0),character.position.set(0,0,0),camera.position.set(0,2,3);
});
}
function onWindowResize(){camera.aspect=window.innerWidth/window.innerHeight,camera.updateProjectionMatrix(),renderer.setSize(window.innerWidth,window.innerHeight)/*,document.querySelector("canvas").style.marginLeft=-((document.querySelector("canvas").style.width.split("px")[0]-0)/2)+"px",document.querySelector("canvas").style.left="50%",document.querySelector("canvas").style.position="relative"*/}window.addEventListener("resize",onWindowResize,!1);
function fire(rounds = 1) {
let isWalking = isw;
stopWalk();
document.querySelector("#gunsound-rifle").cloneNode().play();
let i = 0;
let h = setInterval(() => {
if (i >= rounds) {
return clearInterval(h), (isWalking && walk());
}
i++;
(new THREE.GLTFLoader).load("models/muzzle_flash.glb",(e)=>{e=e.scene;e.position.copy(character.position),e.scale.set(.6,.6,.6),e.rotation.copy(character.rotation),e.updateMatrix(),e.translateY(2.5),e.translateZ(-1.5),e.rotateY(.6),scene.add(e),setTimeout(()=>scene.remove(e),50)});
character.getObjectByName("WeaponConceptACE35Rglb").rotation.x+=.04;
character.getObjectByName("neck_02_071").rotation.z+=.05;
character.getObjectByName("clavicle_r_039").rotation.y+=.1;
setTimeout(() => {
character.getObjectByName("WeaponConceptACE35Rglb").rotation.x+=-.04;
character.getObjectByName("neck_02_071").rotation.z+=-.05;
character.getObjectByName("clavicle_r_039").rotation.y+=-.1;
}, 50);
}, 100);
}
function walk() {
document.querySelector("#walking").currentTime=1.5;
!isw && document.querySelector("#walking").play();
isw = true;
mixer.clipAction(characterAnimations[0]).play();
}
document.addEventListener("keydown", (e) => {
if (e.key == "w") {
e.repeat ? stopWalk() : walk();
}
if (e.key == "f") {
fire(3);
}
});
function stopWalk() {
isw = false;
document.querySelector("#walking").pause();
document.querySelector("#walking").currentTime = 0;
mixer.clipAction(characterAnimations[0]).stop();
mixer.clipAction(characterAnimations[0]).reset();
}
</script>
</body>
</html>