Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var roomName = "[NARS] REAL SOCCER 24/7";
- var maxPlayers = 20;
- var roomPublic = false;
- var playerName = "NARS REF";
- /* STADIUM */
- //Wartości dotyczą boiska na którym rozgrywany jest mecz - wartości domyślne to oficjalna mapa RS
- var stadiumWidth = 1150;
- var stadiumHeight = 600;
- var radiusBall = 9.8;
- var throwInLeeway = 350;
- var greenLine = 510;
- /* SETTINGS */
- var triggerDistance = radiusBall + 15 + 0.01;
- var outLineY = stadiumWidth - (radiusBall / 2) + 6;
- stadiumWidth += (radiusBall / 2) + 6;
- stadiumHeight += (radiusBall / 2) + 6;
- var Team = {
- SPECTATORS: 0,
- RED: 1,
- BLUE: 2
- };
- var lastScores = 0;
- var lastTeamTouched = 0;
- var lineBallPosition;
- var exitingPos = null;
- var previousBallPos;
- var assistingTouch = "";
- var lastPlayerTouched = "";
- var lat = 40;
- var long = -74;
- var backMSG = false;
- var lastCall;
- var isBallUp = false;
- var crossed = false;
- var isTimeAddedShown = false;
- var lineCrossedPlayers = [{name: "temp", times: 0}];
- var isBallKickedOutside = false;
- var previousPlayerTouched;
- var timeOutside = 0;
- var room = HBInit({ roomName: roomName, maxPlayers: maxPlayers, public: roomPublic, playerName: playerName,token: "thr1.AAAAAFyRjgZMy18R2w9YjQ.-FYMqQV18YE", geo: {"code": "CA", "lat": lat, "lon": long }});
- var RSHLMap = `{ "name" : "Real Soccer 1.3D by RawR", "width" : 1300, "height" : 670, "spawnDistance" : 500, "bg" : { "type" : "grass", "width" : 1150, "height" : 600, "kickOffRadius" : 180, "cornerRadius" : 0 },"playerPhysics" : {"bCoef" : 0.5,"invMass" : 0.5,"damping" : 0.96,"acceleration" : 0.12,"kickingAcceleration" : 0.07,"kickingDamping" : 0.96,"kickStrength" : 5.65},"vertexes" : [/* 0 */ { "x" : 0, "y" : 700, "trait" : "kickOffBarrier" },/* 1 */ { "x" : 0, "y" : 180, "trait" : "kickOffBarrier" },/* 2 */ { "x" : 0, "y" : -180, "trait" : "kickOffBarrier" },/* 3 */ { "x" : 0, "y" : -700, "trait" : "kickOffBarrier" }, /* 4 */ { "x" : 1150, "y" : 255, "trait" : "line" },/* 5 */ { "x" : 840, "y" : 255, "trait" : "line" },/* 6 */ { "x" : 1150, "y" : -255, "trait" : "line" }, /* 7 */ { "x" : 840, "y" : -255, "trait" : "line" }, /* 8 */ { "x" : 1150, "y" : 155, "trait" : "line" }, /* 9 */ { "x" : 1030, "y" : 155, "trait" : "line" }, /* 10 */ { "x" : 1150, "y" : -155, "trait" : "line" }, /* 11 */ { "x" : 1030, "y" : -155, "trait" : "line" }, /* 12 */ { "x" : 840, "y" : -135, "trait" : "line", "curve" : -130 }, /* 13 */ { "x" : 840, "y" : 135, "trait" : "line", "curve" : -130 }, /* 14 */ { "x" : -1150, "y" : -255, "trait" : "line", "curve" : -90, "color" : "97AC86" }, /* 15 */ { "x" : -840, "y" : -255, "trait" : "line" }, /* 16 */ { "x" : -1150, "y" : 255, "trait" : "line" }, /* 17 */ { "x" : -840, "y" : 255, "trait" : "line" }, /* 18 */ { "x" : -1150, "y" : -155, "trait" : "line" }, /* 19 */ { "x" : -1030, "y" : -155, "trait" : "line" }, /* 20 */ { "x" : -1150, "y" : 155, "trait" : "line" }, /* 21 */ { "x" : -1030, "y" : 155, "trait" : "line" }, /* 22 */ { "x" : -840, "y" : 135, "trait" : "line", "curve" : -130 }, /* 23 */ { "x" : -840, "y" : -135, "trait" : "line", "curve" : -130 }, /* 24 */ { "x" : 935, "y" : 4, "trait" : "line" }, /* 25 */ { "x" : 935, "y" : -4, "trait" : "line" }, /* 26 */ { "x" : -935, "y" : 4, "trait" : "line" }, /* 27 */ { "x" : -935, "y" : -4, "trait" : "line" }, /* 28 */ { "x" : -1150, "y" : 525, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 29 */ { "x" : -1075, "y" : 600, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line", "_selected" : true }, /* 30 */ { "x" : -1075, "y" : -600, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 31 */ { "x" : -1150, "y" : -525, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 32 */ { "x" : 1075, "y" : 600, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 33 */ { "x" : 1150, "y" : 525, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 34 */ { "x" : 1150, "y" : -525, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 35 */ { "x" : 1075, "y" : -600, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, /* 36 */ { "x" : -1150, "y" : 127, "trait" : "line", "color" : "ffffff" }, /* 37 */ { "x" : -1214, "y" : 124, "trait" : "line", "color" : "ffffff", "curve" : 5 }, /* 38 */ { "x" : -1150, "y" : -127, "trait" : "line", "color" : "ffffff" }, /* 39 */ { "x" : -1214, "y" : -124, "trait" : "line", "color" : "ffffff", "curve" : 5 }, /* 40 */ { "x" : 1150, "y" : 127, "trait" : "line", "color" : "ffffff" }, /* 41 */ { "x" : 1214, "y" : 124, "trait" : "line", "color" : "ffffff", "curve" : -5 }, /* 42 */ { "x" : 1150, "y" : -127, "trait" : "line", "color" : "ffffff" }, /* 43 */ { "x" : 1214, "y" : -124, "trait" : "line", "color" : "ffffff", "curve" : -5 }, /* 44 */ { "x" : 0, "y" : -4, "trait" : "line" }, /* 45 */ { "x" : 0, "y" : 4, "trait" : "line" }, /* 46 */ { "x" : 0, "y" : -4, "trait" : "line" }, /* 47 */ { "x" : 0, "y" : 4, "trait" : "line" }, /* 48 */ { "x" : -1214, "y" : 124, "trait" : "line", "color" : "ffffff" }, /* 49 */ { "x" : -1250, "y" : 150, "trait" : "line", "color" : "ffffff", "pos" : [-1250,150 ] }, /* 50 */ { "x" : -1214, "y" : -124, "trait" : "line", "color" : "ffffff" }, /* 51 */ { "x" : -1250, "y" : -150, "trait" : "line", "color" : "ffffff", "pos" : [-1250,-150 ] }, /* 52 */ { "x" : 1214, "y" : 124, "trait" : "line", "color" : "ffffff" }, /* 53 */ { "x" : 1250, "y" : 150, "trait" : "line", "color" : "ffffff" }, /* 54 */ { "x" : 1214, "y" : -124, "trait" : "line", "color" : "ffffff" }, /* 55 */ { "x" : 1250, "y" : -150, "trait" : "line", "color" : "ffffff" }, /* 56 */ { "x" : -1185, "y" : 155, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : 40, "color" : "BEB86C" }, /* 57 */ { "x" : -1185, "y" : 255, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : 40, "color" : "BEB86C" }, /* 58 */ { "x" : 1185, "y" : 155, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : -40, "color" : "BEB86C" }, /* 59 */ { "x" : 1185, "y" : 255, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : -40, "color" : "BEB86C" }, /* 60 */ { "x" : -1185, "y" : -155, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : -40, "color" : "BEB86C" }, /* 61 */ { "x" : -1185, "y" : -255, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : -40, "color" : "BEB86C" }, /* 62 */ { "x" : 1185, "y" : -155, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : 40, "color" : "BEB86C" }, /* 63 */ { "x" : 1185, "y" : -255, "bCoef" : -4.5, "cMask" : ["ball" ], "trait" : "line", "curve" : 40, "color" : "BEB86C" }, /* 64 */ { "x" : 1158, "y" : -607, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : 0, "color" : "BEB86C" }, /* 65 */ { "x" : 1187, "y" : -578, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : -60, "color" : "BEB86C" }, /* 66 */ { "x" : 1158, "y" : 607, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : 0, "color" : "BEB86C" }, /* 67 */ { "x" : 1187, "y" : 578, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : 60, "color" : "BEB86C" }, /* 68 */ { "x" : -1158, "y" : 607, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : 0, "color" : "BEB86C" }, /* 69 */ { "x" : -1187, "y" : 578, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : -60, "color" : "BEB86C" }, /* 70 */ { "x" : -1158, "y" : -607, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : 0, "color" : "BEB86C" }, /* 71 */ { "x" : -1187, "y" : -578, "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line", "curve" : 60, "color" : "BEB86C" }, /* 72 */ { "x" : -1190, "y" : -255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 73 */ { "x" : -1180, "y" : -255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 74 */ { "x" : -1190, "y" : -155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 75 */ { "x" : -1180, "y" : -155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 76 */ { "x" : -1190, "y" : 155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 77 */ { "x" : -1180, "y" : 155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 78 */ { "x" : -1190, "y" : 255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 79 */ { "x" : -1180, "y" : 255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 80 */ { "x" : 1190, "y" : -255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 81 */ { "x" : 1180, "y" : -255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 82 */ { "x" : 1190, "y" : -155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 83 */ { "x" : 1180, "y" : -155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 84 */ { "x" : 1190, "y" : 255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 85 */ { "x" : 1180, "y" : 255, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 86 */ { "x" : 1190, "y" : 155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 87 */ { "x" : 1180, "y" : 155, "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line", "color" : "000000", "curve" : 0 }, /* 88 */ { "x" : -1148, "y" : -525, "trait" : "line", "curve" : -90, "color" : "5E844D" }, /* 89 */ { "x" : 1148, "y" : -525, "trait" : "line", "color" : "5E844D" }, /* 90 */ { "x" : -1148, "y" : 525, "trait" : "line", "curve" : -90, "color" : "5E844D" }, /* 91 */ { "x" : 1148, "y" : 525, "trait" : "line", "color" : "5E844D" }, /* 92 */ { "x" : -1150, "y" : -260, "trait" : "line", "curve" : -100, "color" : "5E844D" }, /* 93 */ { "x" : -840, "y" : -600, "trait" : "line", "color" : "5E844D", "curve" : -100 }, /* 94 */ { "x" : -1150, "y" : 260, "trait" : "line", "curve" : 100, "color" : "5E844D" }, /* 95 */ { "x" : -840, "y" : 600, "trait" : "line", "color" : "5E844D", "curve" : 100 }, /* 96 */ { "x" : -840, "y" : -1150, "trait" : "line", "color" : "5E844D", "curve" : -100 }, /* 97 */ { "x" : 1150, "y" : -260, "trait" : "line", "curve" : 100, "color" : "5E844D" }, /* 98 */ { "x" : 840, "y" : -600, "trait" : "line", "color" : "5E844D", "curve" : 100 }, /* 99 */ { "x" : 1150, "y" : 260, "trait" : "line", "curve" : -100, "color" : "5E844D" }, /* 100 */ { "x" : 840, "y" : 600, "trait" : "line", "color" : "5E844D", "curve" : -100 } ], "segments" : [ { "v0" : 37, "v1" : 39, "curve" : 5, "color" : "ffffff", "trait" : "reargoalNetleft", "x" : -1210 }, { "v0" : 41, "v1" : 43, "curve" : -5, "color" : "ffffff", "trait" : "reargoalNetright" }, { "v0" : 4, "v1" : 5, "trait" : "line", "y" : 250 }, { "v0" : 5, "v1" : 7, "trait" : "line", "x" : 840 }, { "v0" : 6, "v1" : 7, "trait" : "line", "y" : -250 }, { "v0" : 8, "v1" : 9, "trait" : "line", "y" : 150 }, { "v0" : 9, "v1" : 11, "trait" : "line", "x" : 1030 }, { "v0" : 10, "v1" : 11, "trait" : "line", "y" : -150 }, { "v0" : 12, "v1" : 13, "curve" : -130, "trait" : "line", "x" : 840 }, { "v0" : 14, "v1" : 15, "trait" : "line", "y" : -250 }, { "v0" : 15, "v1" : 17, "trait" : "line", "x" : -840 }, { "v0" : 16, "v1" : 17, "trait" : "line", "y" : 250 }, { "v0" : 18, "v1" : 19, "trait" : "line", "y" : -150 }, { "v0" : 19, "v1" : 21, "trait" : "line", "x" : -1030 }, { "v0" : 20, "v1" : 21, "trait" : "line", "y" : 150 }, { "v0" : 22, "v1" : 23, "curve" : -130, "trait" : "line", "x" : -840 }, { "v0" : 24, "v1" : 25, "curve" : -180, "trait" : "line", "x" : 935 }, { "v0" : 26, "v1" : 27, "curve" : -180, "trait" : "line", "x" : -935 }, { "v0" : 24, "v1" : 25, "curve" : 180, "trait" : "line", "x" : 935 }, { "v0" : 26, "v1" : 27, "curve" : 180, "trait" : "line", "x" : -935 }, { "v0" : 24, "v1" : 25, "curve" : 90, "trait" : "line", "x" : 935 }, { "v0" : 26, "v1" : 27, "curve" : 90, "trait" : "line", "x" : -935 }, { "v0" : 24, "v1" : 25, "curve" : -90, "trait" : "line", "x" : 935 }, { "v0" : 26, "v1" : 27, "curve" : -90, "trait" : "line", "x" : -935 }, { "v0" : 24, "v1" : 25, "trait" : "line", "x" : 935 }, { "v0" : 26, "v1" : 27, "trait" : "line", "x" : -935 }, { "v0" : 28, "v1" : 29, "curve" : 90, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, { "v0" : 30, "v1" : 31, "curve" : 90, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, { "v0" : 32, "v1" : 33, "curve" : 90, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, { "v0" : 34, "v1" : 35, "curve" : 90, "bCoef" : 0, "cMask" : ["wall" ], "trait" : "line" }, { "v0" : 36, "v1" : 37, "curve" : 5, "color" : "ffffff", "trait" : "sidegoalNet" }, { "v0" : 38, "v1" : 39, "curve" : -5, "color" : "ffffff", "trait" : "sidegoalNet" }, { "v0" : 40, "v1" : 41, "curve" : -5, "color" : "ffffff", "trait" : "sidegoalNet" }, { "v0" : 42, "v1" : 43, "curve" : 5, "color" : "ffffff", "trait" : "sidegoalNet" }, { "v0" : 44, "v1" : 45, "curve" : -180, "trait" : "line" }, { "v0" : 46, "v1" : 47, "curve" : 180, "trait" : "line" }, { "v0" : 44, "v1" : 45, "curve" : -90, "trait" : "line" }, { "v0" : 46, "v1" : 47, "curve" : 90, "trait" : "line" }, { "v0" : 48, "v1" : 49, "color" : "ffffff", "trait" : "line" }, { "v0" : 50, "v1" : 51, "color" : "ffffff", "trait" : "line" }, { "v0" : 52, "v1" : 53, "color" : "ffffff", "trait" : "line" }, { "v0" : 54, "v1" : 55, "color" : "ffffff", "trait" : "line" }, { "v0" : 56, "v1" : 57, "curve" : 40, "vis" : true, "color" : "BEB86C", "bCoef" : -4.7, "cMask" : ["ball" ], "trait" : "line", "x" : -1220 }, { "v0" : 58, "v1" : 59, "curve" : -40, "vis" : true, "color" : "BEB86C", "bCoef" : -4.7, "cMask" : ["ball" ], "trait" : "line", "x" : 1220 }, { "v0" : 60, "v1" : 61, "curve" : -40, "vis" : true, "color" : "BEB86C", "bCoef" : -4.7, "cMask" : ["ball" ], "trait" : "line", "x" : -1220 }, { "v0" : 62, "v1" : 63, "curve" : 40, "vis" : true, "color" : "BEB86C", "bCoef" : -4.7, "cMask" : ["ball" ], "trait" : "line", "x" : 1220 }, { "v0" : 64, "v1" : 65, "curve" : -60, "vis" : true, "color" : "BEB86C", "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 66, "v1" : 67, "curve" : 60, "vis" : true, "color" : "BEB86C", "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 68, "v1" : 69, "curve" : -60, "vis" : true, "color" : "BEB86C", "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 70, "v1" : 71, "curve" : 60, "vis" : true, "color" : "BEB86C", "bCoef" : -2.45, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 0, "v1" : 1, "trait" : "kickOffBarrier" }, { "v0" : 1, "v1" : 2, "curve" : 180, "cGroup" : ["blueKO" ], "trait" : "kickOffBarrier" }, { "v0" : 1, "v1" : 2, "curve" : -180, "cGroup" : ["redKO" ], "trait" : "kickOffBarrier" }, { "v0" : 2, "v1" : 3, "trait" : "kickOffBarrier" }, { "v0" : 72, "v1" : 73, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 74, "v1" : 75, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 76, "v1" : 77, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 78, "v1" : 79, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 80, "v1" : 81, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 82, "v1" : 83, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 84, "v1" : 85, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 86, "v1" : 87, "curve" : 0, "vis" : true, "color" : "000000", "bCoef" : -1, "cMask" : ["ball" ], "trait" : "line" }, { "v0" : 88, "v1" : 89, "color" : "5E844D", "trait" : "line", "y" : -475 }, { "v0" : 90, "v1" : 91, "color" : "5E844D", "trait" : "line", "y" : -475 }, { "v0" : 92, "v1" : 93, "curve" : -100, "color" : "5E844D", "trait" : "line", "y" : -475 }, { "v0" : 94, "v1" : 95, "curve" : 100, "color" : "5E844D", "trait" : "line", "y" : -475 }, { "v0" : 97, "v1" : 98, "curve" : 100, "color" : "5E844D", "trait" : "line", "y" : -475 }, { "v0" : 99, "v1" : 100, "curve" : -100, "color" : "5E844D", "trait" : "line", "y" : -475 } ], "goals" : [ { "p0" : [-1160,-124 ], "p1" : [-1160,124 ], "team" : "red" }, { "p0" : [1160,124 ], "p1" : [1160,-124 ], "team" : "blue" } ], "discs" : [ { "pos" : [-1150,127 ], "color" : "FF0000", "bCoef" : 0.5, "trait" : "goalPost" }, { "pos" : [-1150,-127 ], "color" : "FF0000", "bCoef" : 0.5, "trait" : "goalPost" }, { "pos" : [1150,127 ], "color" : "0000FF", "bCoef" : 0.5, "trait" : "goalPost" }, { "pos" : [1150,-127 ], "color" : "0000FF", "bCoef" : 0.5, "trait" : "goalPost" }, { "pos" : [-1250,150 ], "color" : "FF0000", "trait" : "stanchion" }, { "pos" : [-1250,-150 ], "color" : "FF0000", "trait" : "stanchion" }, { "pos" : [1250,150 ], "color" : "0000FF", "trait" : "stanchion", "x" : 1250 }, { "pos" : [1250,-150 ], "color" : "0000FF", "trait" : "stanchion", "x" : 1250 }, { "radius" : 2, "invMass" : 0, "pos" : [-1150,-600 ], "color" : "FFFFFF", "bCoef" : -0.1, "cMask" : ["ball" ], "trait" : "goalPost" }, { "radius" : 2, "invMass" : 0, "pos" : [-1150,600 ], "color" : "FFFFFF", "bCoef" : -0.1, "cMask" : ["ball" ], "trait" : "goalPost" }, { "radius" : 2, "invMass" : 0, "pos" : [1150,-600 ], "color" : "FFFFFF", "bCoef" : -0.1, "cMask" : ["ball" ], "trait" : "goalPost" }, { "radius" : 2, "invMass" : 0, "pos" : [1150,600 ], "color" : "FFFFFF", "bCoef" : -0.1, "cMask" : ["ball" ], "trait" : "goalPost" } ], "planes" : [ { "normal" : [0,1 ], "dist" : -635, "bCoef" : 0, "trait" : "ballArea" }, { "normal" : [0,-1 ], "dist" : -635, "bCoef" : 0, "trait" : "ballArea" }, { "normal" : [0,1 ], "dist" : -670, "bCoef" : 0 }, { "normal" : [0,-1 ], "dist" : -670, "bCoef" : 0 }, { "normal" : [1,0 ], "dist" : -1300, "bCoef" : 0 }, { "normal" : [-1,0 ], "dist" : -1300, "bCoef" : 0.1 }, { "normal" : [1,0 ], "dist" : -1214, "bCoef" : 0, "cMask" : ["ball" ] }, { "normal" : [-1,0 ], "dist" : -1214, "bCoef" : 0, "cMask" : ["ball" ] } ], "traits" : { "ballArea" : { "vis" : false, "bCoef" : 0, "cMask" : ["ball" ] }, "goalPost" : { "radius" : 5, "invMass" : 0, "bCoef" : 2 }, "stanchion" : { "radius" : 3, "invMass" : 0, "bCoef" : 3, "cMask" : ["none" ] }, "cornerflag" : { "radius" : 3, "invMass" : 0, "bCoef" : 0.5, "color" : "FFFF00", "cGroup" : [ ] }, "reargoalNetleft" : { "vis" : true, "bCoef" : 0.1, "cMask" : ["ball","red","blue" ], "curve" : 10, "color" : "C7E6BD" }, "reargoalNetright" : { "vis" : true, "bCoef" : 0.1, "cMask" : ["ball","red","blue" ], "curve" : -10, "color" : "C7E6BD" }, "sidegoalNet" : { "vis" : true, "bCoef" : 1, "cMask" : ["ball","red","blue" ], "color" : "C7E6BD" }, "kickOffBarrier" : { "vis" : false, "bCoef" : 0.1, "cGroup" : ["redKO","blueKO" ], "cMask" : ["red","blue" ] }, "line" : { "vis" : true, "cMask" : [ ], "color" : "C7E6BD" }, "tunnel" : { "vis" : true, "cMask" : ["red","blue" ], "color" : "000000" }, "advertising" : { "vis" : true, "cMask" : ["red","blue" ], "color" : "333333" }, "teambench" : { "vis" : true, "cMask" : [ ], "color" : "000000" }, "manager" : { "radius" : 15, "vis" : true, "cMask" : ["red","blue" ], "invMass" : 0, "color" : "333333" }, "physio" : { "radius" : 15, "vis" : true, "cMask" : ["red","blue" ], "invMass" : 0, "color" : "666666" }, "redsubs" : { "radius" : 15, "vis" : true, "cMask" : ["red","blue" ], "invMass" : 0, "color" : "E56E56" }, "bluesubs" : { "radius" : 15, "vis" : true, "cMask" : ["red","blue" ], "invMass" : 0, "color" : "5689E5" } }, "ballPhysics" : { "invMass" : 1.05, "radius" : 9.8}}`;
- room.setCustomStadium(RSHLMap);
- room.setScoreLimit(3);
- room.setTimeLimit(7);
- function clonekick(player){
- players = room.getPlayerList();
- for (i = 0; i < players.length-1; i++){
- if (player.name == players[i].name){
- room.kickPlayer(player.id,"There is already a user with this name",false);
- }
- }
- }
- var boldedNumbers = '𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗';
- var circledNumbers = '🄋⓵⓶⓷⓸⓹⓺⓻⓼⓽';
- function boldedNumber(num){
- var result = '';
- var reversedDigits = [];
- do{
- reversedDigits.push(num % 10);
- num = Math.floor(num / 10);
- }while(num > 0);
- for (var i = reversedDigits.length; i-- > 0; ){
- result += boldedNumbers.substr(reversedDigits[i]*2, 2);
- }
- return result;
- }
- function circledNumber(num){
- var result = '';
- var reversedDigits = [];
- do{
- reversedDigits.push(num % 10);
- num = Math.floor(num / 10);
- }while(num > 0);
- for (var i = reversedDigits.length; i-- > 0; ){
- if(reversedDigits[i] == 0){
- result += circledNumbers.substr(reversedDigits[i], 2);
- }else{
- result += circledNumbers.substr(1+reversedDigits[i], 1);
- }
- }
- return result;
- }
- /*
- Functions
- */
- // If there are no admins left in the room give admin to one of the remaining players.
- function updateAdmins() {
- // Get all players except the host (id = 0 is always the host)
- var players = room.getPlayerList().filter((player) => player.id != 0 );
- if ( players.length == 0 ){room.stopGame();} // No players left, do nothing.
- if ( players.find((player) => player.admin) != null ) return; // There's an admin left so do nothing.
- room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list
- }
- function initPlayerStats(player){
- }
- /*
- for commands
- */
- function swapFun(player){
- if (player.admin == true){
- if (room.getScores() == null) {
- players = room.getPlayerList();
- for (i = 0; i < players.length; i++){
- if (players[i].team == 1){
- room.setPlayerTeam(players[i].id, 2);
- }
- else if (players[i].team == 2){
- room.setPlayerTeam(players[i].id, 1);
- }
- }
- }
- }
- }
- function pushMuteFun(player, message){ // !mute Anddy
- // Prevent somebody to talk in the room (uses the nickname, not the id)
- // need to be admin
- if (player.admin == true){
- if (!(mutedPlayers.includes(message.substr(6)))) mutedPlayers.push(message.substr(6));
- }
- }
- function gotMutedFun(player){
- if (mutedPlayers.includes(player.name)){
- return true;
- }
- }
- function unmuteFun(player, message){ // !unmute Anddy
- // Allow somebody to talk if he has been muted
- // need to be admin
- if (player.admin == true){
- pos = mutedPlayers.indexOf(message.substr(9));
- mutedPlayers.splice(pos, 1);
- }
- }
- function confirmFun(player, message){ // !confirm aaa
- // Prevent somebody to talk in the room (uses the nickname, not the id)
- // need to be admin
- let password = message.substr(9);
- let account = accounts.find(a => a.password === password);
- if (account !== undefined) {
- account.playerId = player.id;
- room.sendChat("[" + player.name + "] " + account.username + " has confirmed");
- confirmedPlayers.add(player.id);
- if (stats.hasOwnProperty(account.username)){}
- else {stats[account.username] = [0, 0, 0, 0, 0, 0, 1000, "D", "D", "D", "D", "D"];}
- }
- return false;
- }
- function chatasbotFun(player, message){
- messagetext = message.substr(11)
- room.sendChat(messagetext);
- return false;
- }
- function adminFun(player, message){ // !admin Andis
- // Gives admin to the person who type this password
- room.setPlayerAdmin(player.id, true);
- return false; // The message won't be displayed
- }
- function resignFun(player, message){
- room.setPlayerAdmin(player.id, false);
- updateAdmins();
- }
- function helpFun() { // !help
- room.sendChat('💬 Available commands: "!confirm", "!afk", "afks", "!confirmed_players", "!stats Nickname", "!elohelp", "!eloranking", "!ranking",');
- room.sendChat('💬 "!8ball", "!poss", "!resetstats", "!adminhelp", "!gkhelp", "!rankhelp", "!bb"');
- }
- function adminHelpFun() {
- room.sendChat('💬 Available commands: "!mute Player", "!unmute Player", ' +
- '"!clearbans", "!rr", "!kickafks", "!resign", "!swap" (to switch reds and blues).');
- }
- function gkHelpFun() { // !gkhelp
- room.sendChat('💬 The most backward player at the kick off will be set as gk ! (write "!gk" if the bot was wrong).')
- }
- function rankHelpFun() { // !gkhelp
- room.sendChat("💬 Get points by doing good things in this room ! Goal: 2 pts, assist: 1 pts, win: 3 pts, cs: 3 pts, lose: -3 pts, og: -2 pts.")
- }
- function eloHelpFun() {
- room.sendChat("💬 Get points by winning matches ! Points are calculated using elo system.")
- }
- function statsFun(player, message){
- if (stats.hasOwnProperty(message.substr(7))){
- sendStats(message.substr(7));
- } else{ return false;}
- }
- function resetStatsAdminFun (player, message){ // !reset876
- playername = message.substr(10);
- stats[playername] = [0, 0, 0, 0, 0, 0, 1000, "D", "D", "D", "D", "D"];
- return false;
- }
- function clearbansFun(player){ // !clear
- if (player.admin == true){ room.clearBans(); room.sendChat("💎 Bans has been reseted.");}
- }
- function resetFun(player){
- if (player.admin == true){
- room.stopGame();
- room.startGame();
- }
- }
- function gkFun(player){ // !gk
- if (room.getScores() != null && room.getScores().time < 60){
- if (player.team == 1) {
- gk[0] = player;
- }
- else if (player.team == 2){
- gk[1] = player;
- }
- }
- return;
- }
- function closeFun(player){
- if (player.name == "Waffleaaa"){ // artificially generate an error in order to close the room
- stats.crash();
- }
- }
- function leaveFun(player){
- room.kickPlayer(player.id, "ggs!", false);
- }
- /*
- For ranking
- */
- function rankingCalc(player){
- var name = player;
- players = Object.keys(stats);
- account = players.find(a => a === name)
- if (account !== undefined){
- return stats[name][0] * 2 + stats[name][1] * 1 +
- stats[name][2] * 3 + stats[name][5] * 3 -
- stats[name][3] * 3 - stats[name][4] * 2;
- }
- else {return 0;}
- }
- function ranking(){
- var overall = [];
- players = Object.keys(stats);
- for (var i = 0; i < players.length; i++) {
- score = rankingCalc(players[i])
- // Goal: 2 pts, Assist: 1 pts, Win: 3 pts, CS: 3 pts, Lose: -3 pts, OG: -2 pts
- overall.push({name: players[i], value: score});
- }
- overall.sort(function(a,b){
- return b.value - a.value;
- })
- let top15 = overall.splice(0, 15);
- let pos = 1;
- if (top15.length) {
- room.sendChat("💎 Ranking [TOP15]: ");
- }
- while (top15.length) {
- let tmp = top15.splice(0, 5);
- let message = tmp.map(e => `${pos++}) ${e.name}: ${e.value}`).join(", ");
- room.sendChat(message);
- }
- }
- function eloCalc(player){
- var name = player;
- return stats[name][6];
- }
- function eloranking(){
- var overall = [];
- players = Object.keys(stats);
- for (var i = 0; i < players.length; i++) {
- score = eloCalc(players[i])
- // Goal: 2 pts, Assist: 1 pts, Win: 3 pts, CS: 3 pts, Lose: -3 pts, OG: -2 pts
- overall.push({name: players[i], value: score});
- }
- overall.sort(function(a,b){
- return b.value - a.value;
- })
- let top15 = overall.splice(0, 15);
- let pos = 1;
- if (top15.length) {
- room.sendChat("💎 ELO Ranking [TOP15]: ");
- }
- while (top15.length) {
- let tmp = top15.splice(0, 5);
- let message = tmp.map(e => `${pos++}) ${e.name}: ${e.value}`).join(", ");
- room.sendChat(message);
- }
- }
- function sendStats(name){
- ps = stats[name]; // stands for playerstats
- /* if (ps[7] == parseInt(0)) {ps[7] = "L"} else {ps[7] = "W"}
- if (ps[8] == parseInt(0)) {ps[8] = "L"} else {ps[8] = "W"}
- if (ps[9] == parseInt(0)) {ps[9] = "L"} else {ps[9] = "W"}
- if (ps[10] == parseInt(0)) {ps[10] = "L"} else {ps[10] = "W"}
- if (ps[11] == parseInt(0)) {ps[11] = "L"} else {ps[11] = "W"} */
- room.sendChat(name + ": Goals: " + ps[0] + ", Assists: " + ps[1]
- + ", OG: " + ps[4] + ", CS: " + ps[5] + ", Wins: " + ps[2] + ", Losses: " + ps[3] + ", 💎 ELO: " + ps[6]);
- if (ps[7] !== "D" && ps[8] !== "D" && ps[9] !== "D" && ps[10] !== "D" && ps[11] !== "D"){room.sendChat(name + ": 🥇 Last 5 W/L: " + ps[7] + " - " + ps[8] + " - " + ps[9] + " - " + ps[10] + " - " + ps[11]);}
- if (ps[7] !== "D" && ps[8] !== "D" && ps[9] !== "D" && ps[10] !== "D" && ps[11] == "D"){room.sendChat(name + ": 🥇 Last 4 W/L: " + ps[7] + " - " + ps[8] + " - " + ps[9] + " - " + ps[10]);}
- if (ps[7] !== "D" && ps[8] !== "D" && ps[9] !== "D" && ps[10] == "D" && ps[11] == "D"){room.sendChat(name + ": 🥇 Last 3 W/L: " + ps[7] + " - " + ps[8] + " - " + ps[9]);}
- if (ps[7] !== "D" && ps[8] !== "D" && ps[9] == "D" && ps[10] == "D" && ps[11] == "D"){room.sendChat(name + ": 🥇 Last 2 W/L: " + ps[7] + " - " + ps[8]);}
- if (ps[7] !== "D" && ps[8] == "D" && ps[9] == "D" && ps[10] == "D" && ps[11] == "D"){room.sendChat(name + ": 🥇 Last W/L: " + ps[7]);}
- }
- function whichTeam(){ // gives the players in the red or blue team
- var players = room.getPlayerList();
- var redTeam = players.filter(player => player.team == 1);
- var blueTeam = players.filter(player => player.team == 2);
- return [redTeam, blueTeam]
- }
- function afkFun(player, message){ // !classic
- if (afkPlayerIDs.has(player.id)){
- afkPlayerIDs.delete(player.id);
- room.sendChat("💎 " + player.name + " is back! and ready for play!");}
- else {afkPlayerIDs.add(player.id); room.setPlayerTeam(player.id, 0);room.sendChat("💎 " + player.name + " is now AFK!");}
- }
- function afksFun(player, message){ // !huge
- afkPlayers_list = room.getPlayerList().filter((x) => afkPlayerIDs.has(x.id));
- afkPlayers_list_string = afkPlayers_list.map(x => x.name).join(", ");
- if (afkPlayers_list == "") {
- room.sendChat("💎 No AFK players in the room!");
- }
- else {
- room.sendChat("💎 AFK players: " + afkPlayers_list_string);
- }
- }
- function kickafksFun(player, message){ // !huge
- if (player.admin == true){
- afksPlayers = room.getPlayerList().filter((x) => afkPlayerIDs.has(x.id));
- for(var i=0;i<afksPlayers.length;i++){room.kickPlayer(afksPlayers[i].id,"AFK!",false);}
- }
- }
- function saveStatsFun(){
- var val = JSON.stringify(stats);
- window.localStorage.setItem("stats", val);
- return false;
- }
- function getAverageRank(team){
- average = 0;
- for (var i = 0; i < team.length; i++) {
- if (team[i].name !== undefined){
- average += rankingCalc(team[i].name);}
- }
- return average / team.length;
- }
- function getRatingDelta(redTeam, blueTeam, redGameResult, blueGameResult) {
- redAverage = getAverageRank(redTeam);
- blueAverage = getAverageRank(blueTeam);
- var redChanceToWin = 1 / ( 1 + Math.pow(10, (blueAverage - redAverage) / 400));
- var blueChanceToWin = 1 - redChanceToWin;
- return [Math.round(32 * (redGameResult - redChanceToWin)), Math.round(32 * (blueGameResult - blueChanceToWin))];
- }
- function updateElo(redTeam, blueTeam, redGameResult, blueGameResult){
- if (redTeam.length == blueTeam.length && redTeam.length == '4' && blueTeam.length == '4'){
- [redDelta, blueDelta] = getRatingDelta(redTeam, blueTeam, redGameResult, blueGameResult)
- for (var i = 0; i < redTeam.length; i++) {
- let account3 = accounts.find(a => a.playerId === redTeam[i].id);
- if (account3 !== undefined) {stats[account3.username][6] += redDelta;} else{};
- let account4 = accounts.find(a => a.playerId === blueTeam[i].id);
- if (account4 !== undefined) {stats[account4.username][6] += blueDelta;} else{};
- }
- return redDelta;
- }
- return 0;
- }
- function confirmedPlayersFun(player, message){ // !huge
- confirmedPlayers_list = room.getPlayerList().filter((x) => confirmedPlayers.has(x.id));
- confirmedPlayers_list_string = confirmedPlayers_list.map(x => x.name).join(", ");
- if (confirmedPlayers_list == "") {
- room.sendChat("💎 Their is no confirmed players currently!");
- }
- else {
- room.sendChat("💎 Confirmed players: " + confirmedPlayers_list_string);
- }
- }
- function eightballFun(player, message){
- var myArray = ['Hell to the no.', 'Maybe.', 'Pfft.', 'The future is bleak.', 'Certainly not.', 'Ahaha! Really?!?', 'The future is uncertain.', 'Possibly.', 'I hope not.', 'Never!', 'Never, ever, ever.', 'Hell, yes.', 'Not in your wildest dreams.', 'Yes!', 'I hope so.'];
- var rand = myArray[(Math.random() * myArray.length) | 0]
- var myArray2 = ['😀','😁','😂','😃','😄','😅','😆','😉','😊','😋','😎','😍','😘','😏','😣','😥','😮','😯','😪','😫','😴','😌','😛','😜','😝'];
- var randimage = myArray2[(Math.random() * myArray2.length) | 0]
- room.sendChat(randimage + " " + rand);
- }
- function setpasswordFun(player, message){ //!set_password !confirm
- if (player.admin == true){
- code = message.substr(14)
- room.setPassword(code);
- room.sendChat("💎 Room locked.");
- return false;
- }
- }
- function clearpasswordFun(player, message){ //!clear_password
- if (player.admin == true){
- room.setPassword();
- room.sendChat("💎 Room unlocked.");
- return false;
- }
- }
- function backaccountFun(player, message){ //!back876 waffle 10 2 3 2 1 1 1000
- if (player.admin == true){
- var playername = message.substring(message.lastIndexOf(":") + 1,message.lastIndexOf(";"));
- var index = message.substr( message.lastIndexOf(";") + 1 ).split(" ");
- var goals = index[1]
- var assists = index[2]
- var wins = index[3]
- var losses = index[4]
- var og = index[5]
- var cs = index[6]
- var elo = index[7]
- var ws1 = index[8]
- var ws2 = index[9]
- var ws3 = index[10]
- var ws4 = index[11]
- var ws5 = index[12]
- stats[playername] = [parseInt(goals), parseInt(assists), parseInt(wins), parseInt(losses), parseInt(og), parseInt(cs), parseInt(elo), ws1, ws2, ws3, ws4, ws5]; // goals, assists, wins, losses, og, cs, elo
- saveStatsFun();
- return false;
- }
- }
- function addaccountFun(player, message){ //!addaccount Waffle aaa
- var playername = message.substring(message.lastIndexOf(":") + 1,message.lastIndexOf(";"));
- var index = message.substr( message.lastIndexOf(";") + 1 ).split(" ");
- var password = index[index.length - 1]
- accounts.push({username: playername,password: password});
- if (stats.hasOwnProperty(playername)){}
- else {stats[playername] = [0, 0, 0, 0, 0, 0, 1000, "D", "D", "D", "D", "D"];}
- saveStatsFun();
- return false;
- }
- /* function pmFun(player, message){ //!pm
- var pm = message.substr(4);
- var index = message.split(" ").slice(1);
- var playerID = index[0]
- var message2 = message.substr(4).substr(playerID);
- var message3 = "[PM FROM " + player.name + "(ID:" + player.id + ")]: " + message2;
- console.log(playerID);
- console.log(index);
- console.log(message);
- console.log(message2);
- console.log(message3);
- room.sendChat(message3, parseInt(playerID))
- var players = room.getPlayerList().filter((player) => player.id != 0 );
- if ( players.find((player => player.id === playerID))) {room.sendChat("User ID is not found!, Check # for getting ID.", player.id)}
- else {room.sendChat("PM Sent!", player.id)};
- return false;
- } */
- function isGk(){ // gives the mosts backward players before the first kickOff
- var players = room.getPlayerList();
- var min = players[0];
- min.position = {x: room.getBallPosition().x + 60}
- var max = min;
- for (var i = 0; i < players.length; i++) {
- if (players[i].position != null){
- if (min.position.x > players[i].position.x) min = players[i];
- if (max.position.x < players[i].position.x) max = players[i];
- }
- }
- return [min, max]
- }
- function updateWinLoseStats(winners, losers){
- for (var i = 0; i < winners.length; i++) {
- let account = accounts.find(a => a.playerId === winners[i].id);
- if (account !== undefined) {stats[account.username][2] += 1;} else{};
- }
- for (var i = 0; i < losers.length; i++) {
- let account1 = accounts.find(a => a.playerId === losers[i].id);
- if (account1 !== undefined) {stats[account1.username][3] += 1;} else{};
- }
- }
- function updateWinLoseStreakStats(winners, losers){
- if (redTeam.length == blueTeam.length && redTeam.length == '4' && blueTeam.length == '4'){
- for (var i = 0; i < winners.length; i++) {
- let account = accounts.find(a => a.playerId === winners[i].id);
- if (account !== undefined) {
- if (stats[account.username][10] == "W"){ stats[account.username][11] = "W"; } else if (stats[account.username][10] == "L"){ stats[account.username][11] = "L"; } else{};
- if (stats[account.username][9] == "W"){ stats[account.username][10] = "W"; } else if (stats[account.username][9] == "L"){ stats[account.username][10] = "L"; } else{};
- if (stats[account.username][8] == "W"){ stats[account.username][9] = "W"; } else if (stats[account.username][8] == "L"){ stats[account.username][9] = "L"; } else{};
- if (stats[account.username][7] == "W"){ stats[account.username][8] = "W"; } else if (stats[account.username][7] == "L"){ stats[account.username][8] = "L"; } else{};
- stats[account.username][7] = "W";} else{};
- }
- for (var i = 0; i < losers.length; i++) {
- let account1 = accounts.find(a => a.playerId === losers[i].id);
- if (account1 !== undefined) {
- if (stats[account1.username][10] == "W"){ stats[account1.username][11] = "W"; } else if (stats[account1.username][10] == "L"){ stats[account1.username][11] = "L"; } else{};
- if (stats[account1.username][9] == "W"){ stats[account1.username][10] = "W"; } else if (stats[account1.username][9] == "L"){ stats[account1.username][10] = "L"; } else{};
- if (stats[account1.username][8] == "W"){ stats[account1.username][9] = "W"; } else if (stats[account1.username][8] == "L"){ stats[account1.username][9] = "L"; } else{};
- if (stats[account1.username][7] == "W"){ stats[account1.username][8] = "W"; } else if (stats[account1.username][7] == "L"){ stats[account1.username][8] = "L"; } else{};
- stats[account1.username][7] = "L";} else{};
- }
- }
- }
- function initBallCarrying(redTeam, blueTeam){
- var ballCarrying = new Map();
- var playing = redTeam.concat(blueTeam);
- for (var i = 0; i < playing.length; i++) {
- ballCarrying.set(playing[i].name, [0, playing[i].team]); // secs, team, %
- }
- return ballCarrying;
- }
- function updateTeamPoss(value){
- if (value[1] == 1) redPoss += value[0];
- if (value[1] == 2) bluePoss += value[0];
- }
- var bluePoss;
- var redPoss;
- var timeOnHalves;
- function teamPossFun(){
- if (room.getScores() == null) return false;
- bluePoss = 0;
- redPoss = 0
- ballCarrying.forEach(updateTeamPoss);
- var redPossPercent = Math.round((redPoss / (redPoss + bluePoss + 0.000001)) * 100);
- var bluePossPercent = Math.round((bluePoss / (redPoss + bluePoss + 0.000001)) * 100);
- room.sendChat("⛹ Ball possession: Red 🔴 " + boldedNumber(redPossPercent) + "% - " + boldedNumber(bluePossPercent) + "% Blue 🔵" );
- var timeOnRedHalf = Math.round((timeOnHalves[0] / (timeOnHalves[0] + timeOnHalves[1] + 0.000001)) * 100);
- var timeOnBlueHalf = Math.round((timeOnHalves[1] / (timeOnHalves[0] + timeOnHalves[1] + 0.000001)) * 100);
- room.sendChat("◧ Game time on halves : 🔴 " + boldedNumber(timeOnRedHalf) + "% - " + boldedNumber(timeOnBlueHalf) + "% 🔵" );
- }
- /*
- For the game
- */
- // Gives the last player who touched the ball, works only if the ball has the same
- // size than in classics maps.
- var radiusBall = 10;
- function getLastTouchTheBall(lastPlayerTouched, time) {
- var ballPosition = room.getBallPosition();
- var players = room.getPlayerList();
- for(var i = 0; i < players.length; i++) {
- if(players[i].position != null) {
- var distanceToBall = pointDistance(players[i].position, ballPosition);
- if(distanceToBall < triggerDistance) {
- lastPlayerTouched = players[i];
- return lastPlayerTouched;
- }
- }
- }
- return lastPlayerTouched;
- }
- // Calculate the distance between 2 points
- function pointDistance(p1, p2) {
- var d1 = p1.x - p2.x;
- var d2 = p1.y - p2.y;
- return Math.sqrt(d1 * d1 + d2 * d2);
- }
- function isOvertime(){
- scores = room.getScores();
- if (scores != null){
- if (scores.timeLimit != 0){
- if (scores.time > scores.timeLimit){
- if (scores.red == 0 && hasFinished == false){
- let account = accounts.find(a => a.playerId === gk[0].id);
- if (account !== undefined) {
- stats[account.username][5] += 1;}else{};
- let account1 = accounts.find(a => a.playerId === gk[1].id);
- if (account1 !== undefined) {
- stats[account1.username][5] += 1;}else{};
- hasFinished = true;
- }
- }
- }
- }
- }
- // return: the name of the team who took a goal
- var team_name = team => team == 1 ? "🔴 Red" : "🔵 Blue";
- var team_color = team => team == 1 ? "🔴" : "🔵";
- // return: whether it's an OG
- var isOwnGoal = (team, player) => team != player.team ? " [OG]" : "";
- // return: a better display of the second when a goal is scored
- var floor = s => s < 10 ? "0" + s : s;
- // return: whether there's an assist
- //var playerTouchedTwice = playerList => playerList[0].team == playerList[1].team ? " (" + playerList[1].name + ")" : "";
- playerTouchedTwice = function(playerList){
- let account = accounts.find(a => a.playerId === playerList[1].id);
- if (playerList[0].team == playerList[1].team && account !== undefined){ return " (" + playerList[1].name + "[" + account.username + "]" + ")"; }
- else if (playerList[0].team == playerList[1].team && account == undefined){ return " (" + playerList[1].name + ")"; }
- else{ return "";};
- }
- var stats;
- if (!(localStorage.getItem("stats"))){
- stats = {};
- } else {stats = JSON.parse(localStorage.getItem("stats"));}
- window.setInterval(saveStatsFun, 300000);
- /* window.setInterval(saveStatsFun, 300000); */
- var mutedPlayers = []; // Array where will be added muted players
- const confirmedPlayers = new Set()
- const afkPlayerIDs = new Set()
- var init = "init"; // Smth to initialize smth
- init.id = 0; // Faster than getting host's id with the method
- init.name = "init";
- var scorers ; // Map where will be set all scorers in the current game (undefined if reset or end)
- var whoTouchedLast; // var representing the last player who touched the ball
- var whoTouchedBall = [init, init]; // Array where will be set the 2 last players who touched the ball
- var gk = [init, init];
- var goalScored = false;
- let accounts = [];
- accounts.push({username: "Waffle",password: "waf234"});
- accounts.push({username: "Ronaldeano",password: "ronhasfatcock0521"});
- accounts.push({username: "King Natex",password: "kngnatex"});
- accounts.push({username: "Wino",password: "slowball21"});
- accounts.push({username: "Mercurial",password: "sk30"});
- accounts.push({username: "Klister",password: "bigcock10"});
- accounts.push({username: "Sergi Roberto",password: "Veserto"});
- accounts.push({username: "Gluee",password: "87"});
- accounts.push({username: "earth",password: "txtesla"});
- accounts.push({username: "Mecha112",password: "bt46"});
- accounts.push({username: "champagnepapi",password: "bbg1903"});
- accounts.push({username: "Faraone",password: "culpables"});
- accounts.push({username: "Time Lord",password: "1988"});
- accounts.push({username: "Nou",password: "nouisthebest1010"});
- accounts.push({username: "WAZZA",password: "WAZZA10"});
- accounts.push({username: "Gelson Martins",password: "gudelj86"});
- accounts.push({username: "ChiCharito",password: "lozano22"});
- accounts.push({username: "Xavi",password: "skeetandyeet"});
- accounts.push({username: "Kaz",password: "hundred1"});
- accounts.push({username: "magor",password: "thalassa"});
- accounts.push({username: "Nogo",password: "iamJamaican"});
- accounts.push({username: "VR6",password: "nosevr6"});
- accounts.push({username: "Mariano Diaz",password: "rumania1"});
- accounts.push({username: "Bump",password: "bump3616"});
- accounts.push({username: "Rorschach",password: "slowbrained"});
- accounts.push({username: "darko",password: "dorko"});
- accounts.push({username: "ᴱᴰᴮᴱᴿᴳ",password: "sChatzschneidE83r"});
- accounts.push({username: "mané",password: "bk11"});
- accounts.push({username: "Nigel Farage",password: "88888"});
- accounts.push({username: "Ben Simmons",password: "animefan"});
- accounts.push({username: "27",password: "twentyseven"});
- accounts.push({username: "best",password: "2340"});
- accounts.push({username: "BetoForPresident2020",password: "ebk1996"});
- accounts.push({username: "ant",password: "stickarena123"});
- accounts.push({username: "chad",password: "puss"});
- accounts.push({username: "brad",password: "cockinass"});
- accounts.push({username: "Calument",password: "MU2004"});
- accounts.push({username: "henry burris",password: "wombat"});
- accounts.push({username: "geoff",password: "mama"});
- accounts.push({username: "West",password: "7656"});
- accounts.push({username: "prestige",password: "nopreference"});
- accounts.push({username: "burr",password: "b0rr"});
- accounts.push({username: "Lukas",password: "hyperbiird"});
- accounts.push({username: "S.Ramos",password: "SergioR4RMadrid"});
- accounts.push({username: "⊕šαmα",password: "135246sa"});
- accounts.push({username: "Hɨddэn Gэm",password: "1996"});
- accounts.push({username: "feneria",password: "biko"});
- accounts.push({username: "Bigfatsnoozy",password: "opensesame"});
- accounts.push({username: "Luciano",password: "xqef7"});
- accounts.push({username: "Kevinm31",password: "osu"});
- accounts.push({username: "Lindros",password: "kaleshake"});
- accounts.push({username: "Compass",password: "gaygayass123"});
- accounts.push({username: "Derrick Rose",password: "reize27"});
- accounts.push({username: "Ant",password: "ownit41"});
- accounts.push({username: "Panda",password: "1227rg"});
- accounts.push({username: "Starcrushed",password: "cocochanel"});
- accounts.push({username: "guid",password: "cock"});
- accounts.push({username: "dzeko",password: "BOsna123"});
- accounts.push({username: "pixel",password: "niggerssmellbad"});
- accounts.push({username: "knowledge",password: "purplevase"});
- accounts.push({username: "House of Balloons",password: "pirlo5"});
- accounts.push({username: "Messi Da Best",password: "FCB2013"});
- accounts.push({username: "Matt",password: "Brian61202"});
- accounts.push({username: "kpa",password: "geoff"});
- var commands = {
- // Command that doesnt need to know players attributes.
- "!help": helpFun,
- "!gkhelp": gkHelpFun,
- "!adminhelp": adminHelpFun,
- "!rankhelp": rankHelpFun,
- "!ranking": ranking,
- "!poss": teamPossFun,
- "!elohelp": eloHelpFun,
- "!eloranking": eloranking,
- "!reset824": resetStatsAdminFun,
- // Command that need to know who is the player.
- "!gk": gkFun,
- "!despacito105": adminFun,
- // Command that need to know if a player is admin.
- "!swap": swapFun,
- "!rr": resetFun,
- "!clearbans": clearbansFun,
- "!close876": closeFun,
- "!save876": saveStatsFun,
- // Command that need to know what's the message.
- "!stats": statsFun,
- "!addaccount824": addaccountFun,
- "!bb" : leaveFun,
- "!leave" : leaveFun,
- "!quit" : leaveFun,
- "!confirm" : confirmFun,
- "!confirmed_players" : confirmedPlayersFun,
- "!afk" : afkFun,
- "!afks" : afksFun,
- "!kickafks" : kickafksFun,
- "!resign" : resignFun,
- "!chatasbot" : chatasbotFun,
- "!mute" : pushMuteFun,
- "!8ball" : eightballFun,
- "!downloadstats" : backupServerData,
- "!unmute": unmuteFun,
- "!set_password876": setpasswordFun,
- "!clear_password876": clearpasswordFun,
- /* "!pm": pmFun,
- */ "!back876": backaccountFun
- }
- initPlayerStats(room.getPlayerList()[0]) // lazy lol, i'll fix it later
- initPlayerStats(init);
- room.onGameStart = function(player) {
- lineCrossedPlayers = [{name: "temp", times: 0}];
- lastScores = room.getScores().red + room.getScores().blue;
- timeOutside = 0;
- isTimeAddedShown = false;
- lineBallPosition = 0;
- [redTeam,blueTeam] = whichTeam();
- ballCarrying = initBallCarrying(redTeam, blueTeam);
- timeOnHalves = [0,0];
- }
- room.onPlayerTeamChange = function(player){
- if (room.getScores() != null){
- if (1 <= player.team <= 2) ballCarrying.set(player.name, [0, player.team]);
- }
- if (player.team !== 0 && afkPlayerIDs.has(player.id))
- {room.setPlayerTeam(player.id, 0)
- room.sendChat("💎 " + player.name + " is AFK!")}
- if (player.id <= 0){
- room.setPlayerTeam(player.id, 0)}
- }
- room.onPlayerChat = function(player, message) {
- if (mutedPlayers.includes(player.name)) return false;
- let spacePos = message.search(" ");
- let command = message.substr(0, spacePos !== -1 ? spacePos : message.length);
- if (commands.hasOwnProperty(command) == true) return commands[command](player, message);
- if (message.indexOf("!") == 0) return false;
- }
- room.onPlayerBallKick = function(player) {
- whoTouchedLast = player;
- var ballPosition = room.getBallPosition();
- if(player.name!=lastPlayerTouched)
- {
- if(lastTeamTouched==player.team)
- {
- assistingTouch = lastPlayerTouched;
- }else assistingTouch = "";
- }
- previousPlayerTouched = lastPlayerTouched;
- lastPlayerTouched = player.name;
- lastTeamTouched = player.team;
- if(isBallOutsideStadium)
- {
- getPlayersNotWithinLine();
- }
- if(isBallOutsideStadium && ballPosition.y<0)
- {
- isBallKickedOutside = true;
- }else if(isBallOutsideStadium && ballPosition.y>0)
- {
- isBallKickedOutside = true;
- }else isBallKickedOutside = false;
- }
- function isBallGoingUp() {
- previousBallPosForGoingUp = currentBallPosForGoingUp;
- currentBallPosForGoingUp = room.getBallPosition().y;
- if (previousBallPosForGoingUp - currentBallPosForGoingUp > 0.01) {
- isBallUp = 2;
- } else if (previousBallPosForGoingUp - currentBallPosForGoingUp < -0.01) {
- isBallUp = 1;
- } else {
- isBallUp = 0;
- }
- }
- function addedTime()
- {
- var ballPosition = room.getBallPosition();
- if(isOutsideStadium(ballPosition))
- {
- timeOutside++;
- return true;
- }
- }
- function checkEnd() {
- var scores = room.getScores();
- if (scores.time > 590 && !isTimeAddedShown) {
- var actualTimeAdded = Math.round((timeOutside-(100*60))/120);
- if(actualTimeAdded<60&&actualTimeAdded>-1)
- {
- room.sendChat("ADDED TIME: + " + actualTimeAdded + " SECONDS");
- }else if(actualTimeAdded<0)
- {
- room.sendChat("NO ADDED TIME. (+0)");
- }else
- {
- room.sendChat("ADDED TIME: + 1 MINUTE");
- }
- isTimeAddedShown = true;
- }
- }
- var tickCount = 0;
- var kickOff = false;
- var hasFinished = false;
- room.onGameTick = function() {
- if (kickOff == false) { // simplest comparison to not charge usulessly the tick thing
- if (room.getScores().time != 0){
- kickOff = true;
- gk = isGk();
- let account = accounts.find(a => a.playerId === gk[0].id);
- let account1 = accounts.find(a => a.playerId === gk[1].id);
- if (account == undefined && account1 == undefined) {room.sendChat("Red GK: " + gk[0].name + ", Blue GK: " + gk[1].name)}
- else if (account !== undefined && account1 == undefined) {room.sendChat("Red GK: " + gk[0].name + "[" + account.username + "]" + ", Blue GK: " + gk[1].name)}
- else if (account == undefined && account1 !== undefined) {room.sendChat("Red GK: " + gk[0].name + ", Blue GK: " + gk[1].name + "[" + account1.username + "]")}
- else{room.sendChat("Red GK: " + gk[0].name + "[" + account.username + "]" + ", Blue GK: " + gk[1].name + "[" + account1.username + "]")};
- }
- }
- if (goalScored == false){
- whoTouchedLast = getLastTouchTheBall(whoTouchedLast);
- }
- if (whoTouchedLast != undefined) {
- if (ballCarrying.get(whoTouchedLast.name)) {
- ballCarrying.get(whoTouchedLast.name)[0] += 1/60;
- }
- if ( whoTouchedLast.id != whoTouchedBall[0].id){
- whoTouchedBall[1] = whoTouchedBall[0];
- whoTouchedBall[0] = whoTouchedLast; // last player who touched the ball
- }
- }
- updateTimeOnHalves();
- isThrowInCorrect();
- getLastTouchTheBalltwo();
- checkBallPosition();
- isBackRequired();
- hasBallLeftTheLine();
- addedTime();
- checkEnd();
- tickCount++;
- }
- updateTimeOnHalves = function(){
- if(room.getBallPosition().x < 0){
- timeOnHalves[0] += 1/60;
- }else if(room.getBallPosition().x > 0){
- timeOnHalves[1] += 1/60;
- }
- }
- room.onTeamGoal = function(team){ // Write on chat who scored and when.
- goalScored = true;
- var time = room.getScores().time;
- var m = Math.trunc(time/60); var s = Math.trunc(time % 60);
- time = m + ":" + floor(s); // MM:SS format
- var ownGoal = isOwnGoal(team, whoTouchedBall[0]);
- var assist = "";
- if (ownGoal == "") assist = playerTouchedTwice(whoTouchedBall);
- let account = accounts.find(a => a.playerId === whoTouchedBall[0].id);
- if (account !== undefined) {
- room.sendChat("⚽ GOAL scored by " + whoTouchedBall[0].name + "[" + account.username + "]" +
- assist + ownGoal + " at [" +
- time + "] for team " + team_name(team));
- room.sendChat("Match Score now: " + team_color(1) + " " +
- boldedNumber(room.getScores().red) + " - " + boldedNumber(room.getScores().blue) + " " + team_color(2));
- if (ownGoal != "") {
- stats[account.username][4] += 1;
- } else {
- stats[account.username][0] += 1;
- }
- }
- else {
- room.sendChat("⚽ GOAL scored by " + whoTouchedBall[0].name +
- assist + ownGoal + " at [" +
- time + "] for team " + team_name(team));
- room.sendChat("Match Score now: " + team_color(1) + " " +
- boldedNumber(room.getScores().red) + " - " + boldedNumber(room.getScores().blue) + " " + team_color(2));
- }
- let account1 = accounts.find(a => a.playerId === whoTouchedBall[1].id);
- if (account1 !== undefined) {
- if (whoTouchedBall[1] != init && assist != "") stats[account1.username][1] += 1;
- }
- else{
- if (whoTouchedBall[1] != init && assist != "");
- }
- if (scorers == undefined) scorers = new Map(); // Initializing dict of scorers
- scorers.set(scorers.size + 1 +") " + whoTouchedLast.name, [time, assist, ownGoal])
- whoTouchedBall = [init, init];
- whoTouchedLast = undefined;
- saveStatsFun();
- }
- room.onPositionsReset = function(){
- goalScored = false;
- }
- room.onTeamVictory = function(scores){ // Sum up all scorers since the beginning of the match.
- let account = accounts.find(a => a.playerId === gk[0].id);
- if (account !== undefined && scores.blue == 0 && gk[0].position != null && hasFinished == false)
- {stats[account.username][5] += 1;}else {};
- let account1 = accounts.find(a => a.playerId === gk[1].id);
- if (account1 !== undefined && scores.red == 0 && gk[1].position != null && hasFinished == false)
- {stats[account1.username][5] += 1;}else {};
- if (scores.red > scores.blue) {
- eloDelta = updateElo(redTeam, blueTeam, 1, 0);
- updateWinLoseStats(redTeam, blueTeam);
- updateWinLoseStreakStats(redTeam, blueTeam);
- }
- else{
- eloDelta = updateElo(redTeam, blueTeam, 0, 1);
- updateWinLoseStats(blueTeam, redTeam);
- updateWinLoseStreakStats(blueTeam, redTeam);
- }
- room.sendChat("Scored goals ⚽:")
- for (var [key, value] of scorers) { // key: name of the player, value: time of the goal
- room.sendChat(key + " " + value[1] + value[2] + ": " + value[0]);
- }
- room.sendChat("The game cost " + Math.abs(eloDelta) + " points. [ELO Points UPDATED only on 4vs4!]")
- teamPossFun();
- room.stopGame();
- players = room.getPlayerList();
- for (var i = 0; i < players.length; i++) {
- room.setPlayerTeam(players[i].id, 0);
- }
- saveStatsFun();
- }
- room.onGameStop = function(){
- scorers = undefined;
- whoTouchedBall = [init, init];
- whoTouchedLast = undefined;
- gk = [init, init];
- kickOff = false;
- hasFinished = false;
- }
- function getNewRating(myRating, opponentRating, myGameResult) {
- return myRating + getRatingDelta(myRating, opponentRating, myGameResult);
- }
- var _savestatsInterval = 1000 * 10800;
- SaveStats = setInterval(function() {saveStatsFun();},_savestatsInterval);
- function download(data, filename, type) {
- var file = new Blob([data], {type: type});
- var a = document.createElement("a"),
- url = URL.createObjectURL(file);
- a.href = url;
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- setTimeout(function() {
- document.body.removeChild(a);
- window.URL.revokeObjectURL(url);
- }, 0);
- }
- function backupServerData() {
- let jsonData = JSON.stringify(stats);
- download(jsonData, "server_stats.txt", "text/plain");
- return false;
- }
- var _downloadstatsInterval = 1000 * 10800;
- DownladStats = setInterval(function() {backupServerData();},_downloadstatsInterval);
- room.onPlayerJoin = function(player) {
- clonekick(player);
- playerName = player.name.replace(/ /g,"_");
- room.sendChat("💬 Hi @" + playerName + " !" )
- room.sendChat("@" + playerName + " Write !help, !adminhelp, !rankhelp for commands." )
- room.sendChat("@" + playerName + " --> Confirm now to get your stats saved.[!confirm password]" )
- var players = room.getPlayerList();
- var adminNumber = 0;
- for (var i = 0; i < players.length; i++) {
- if (players[i].admin) {
- adminNumber++;
- }
- }
- if (adminNumber < 2) {
- room.setPlayerAdmin(players[1].id, true);
- }
- }
- room.onPlayerLeave = function(player) {
- var players = room.getPlayerList();
- var adminNumber = 0;
- for (var i = 0; i < players.length; i++) {
- if (players[i].admin) {
- adminNumber++;
- }
- }
- if (adminNumber < 2) {
- room.setPlayerAdmin(players[1].id, true);
- }
- }
- function isOutsideStadium(ballPosition) {
- return ballPosition.x > stadiumWidth || ballPosition.x < -stadiumWidth || ballPosition.y > stadiumHeight || ballPosition.y < -stadiumHeight;
- }
- var isBallOutsideStadium = false;
- function checkBallPosition() {
- var ballPosition = room.getBallPosition();
- if(isOutsideStadium(ballPosition)) {
- if(!isBallOutsideStadium) {
- isBallOutsideStadium = true;
- exitingPos = ballPosition.x;
- var totalScores = room.getScores().red + room.getScores().blue;
- if(lastScores != totalScores) {
- lastScores = totalScores;
- return false;
- }
- if(ballPosition.x > stadiumWidth && lastTeamTouched == Team.RED || ballPosition.x < -stadiumWidth && lastTeamTouched == Team.BLUE) {
- lastCall = "GK";
- room.sendChat("GK");
- }
- else if(ballPosition.x > stadiumWidth && lastTeamTouched == Team.BLUE || ballPosition.x < -stadiumWidth && lastTeamTouched == Team.RED) {
- room.sendChat("CK");
- lastCall = "CK";
- }
- else {
- isBallKickedOutside = false;
- room.sendChat(lastTeamTouched == Team.RED ? "B" : "R");
- lastCall = lastTeamTouched == Team.RED ? "2" : "1";
- }
- }
- }
- else {
- isBallOutsideStadium = false;
- backMSG = true;
- }
- return true;
- }
- function getLastTouchTheBalltwo() {
- var ballPosition = room.getBallPosition();
- var players = room.getPlayerList();
- for(var i = 0; i < players.length; i++) {
- if(players[i].position != null) {
- var distanceToBall = pointDistance(players[i].position, ballPosition);
- if(distanceToBall < triggerDistance) {
- if(lastPlayerTouched!=players[i].name)
- {
- if(lastTeamTouched==players[i].team)
- {
- assistingTouch = lastPlayerTouched;
- }else assistingTouch = "";
- }
- lastTeamTouched = players[i].team;
- previousPlayerTouched == lastPlayerTouched;
- lastPlayerTouched = players[i].name;
- }
- }
- }
- return lastPlayerTouched;
- }
- /*
- function filter(message)
- {
- message = message.toLowerCase();
- message = message.replace(/\s/g, '');
- message = message.replace(/\./g,' ')
- if(message.includes("pizd") || message.includes("pedal") || message.includes("retard") || message.includes("debil") || message.includes("idiot") || message.includes("kurw") || message.includes("pierd") || message.includes("jeb") || message.includes("fuck") || message.includes("szmat") || message.includes("bitch") || message.includes("suck") || message.includes("dick") || message.includes("sikerim") || message.includes("orospu") || message.includes("çocuğu") || message.includes("scheiße") || message.includes("dich") || message.includes("fick") || message.includes("hure") || message.includes("ass") || message.includes("whore") || message.includes("shit") || message.includes("gown") || message.includes("huj") || message.includes("dziwk") ||message.includes("kutas"))
- {
- return true;
- }else return false;
- }
- room.onPlayerChat = function(player, message) {
- if(filter(message))
- {
- return false;
- }
- }
- */
- function pointDistance(p1, p2) {
- var d1 = p1.x - p2.x;
- var d2 = p1.y - p2.y;
- return Math.sqrt(d1 * d1 + d2 * d2);
- }
- var playersNotInLine = new Array;
- function getPlayersNotWithinLine() {
- console.log("test");
- playersNotInLine = new Array;
- var players = room.getPlayerList();
- for (var i = 0; i < players.length; i++) {
- if (players[i].position != null) {
- if (players[i].team != lastTeamTouched && players[i].team != lastCall && lastCall != "CK" && lastCall != "GK") {
- if ((players[i].position.y > greenLine || players[i].position.y < -greenLine) && pointDistance(room.getBallPosition(), players[i].position) < 500) {
- playersNotInLine.push(players[i].name);
- }
- }
- }
- }
- }
- function checkPlayersLine() {
- console.log("2");
- for(var i = 0; i < playersNotInLine.length; i++)
- {
- var found = false;
- for (var j = 0; j < lineCrossedPlayers.length; j++) {
- if (lineCrossedPlayers[j].name == playersNotInLine[i]) {
- lineCrossedPlayers[j].times = lineCrossedPlayers[j].times + 1;
- room.sendChat("LINE - " + lineCrossedPlayers[j].name + " {" + lineCrossedPlayers[j].times + "}");
- found = true;
- }
- }
- if (!found) {
- lineCrossedPlayers.push({
- name: playersNotInLine[i],
- times: 1,
- punished: false
- });
- room.sendChat("LINE - " + playersNotInLine[i] + " {1}");
- }
- }
- }
- var trigger = false;
- var wrongThrowPosition = false;
- function isBackRequired()
- {
- var ballPosition = room.getBallPosition();
- if(!isBallKickedOutside)
- {
- if(lastCall=="1")
- {
- if((ballPosition.x - exitingPos > throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition) && ((ballPosition.y - outLineY > 20) || (ballPosition.y - outLineY < -20)))
- {
- backMSG = false;
- room.sendChat("BACK");
- trigger = true;
- wrongThrowPosition = true;
- }
- if((ballPosition.x - exitingPos < -throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition) && ((ballPosition.y - outLineY > 20) || (ballPosition.y - outLineY < -20)))
- {
- backMSG = false;
- room.sendChat("FURTHER");
- trigger = true;
- wrongThrowPosition = true;
- }
- }
- if(lastCall=="2")
- {
- if((ballPosition.x - exitingPos > throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition) && ((ballPosition.y - outLineY > 20) || (ballPosition.y - outLineY < -20)))
- {
- backMSG = false;
- room.sendChat("FURTHER");
- trigger = true;
- wrongThrowPosition = true;
- }
- if((ballPosition.x - exitingPos < -throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition) && ((ballPosition.y - outLineY > 20) || (ballPosition.y - outLineY < -20)))
- {
- backMSG = false;
- room.sendChat("BACK");
- trigger = true;
- wrongThrowPosition = true;
- }
- }
- }
- if(lastCall=="2" && trigger && isOutsideStadium && Math.abs(exitingPos - ballPosition.x)< throwInLeeway-20)
- {
- room.sendChat("OK");
- trigger = false;
- wrongThrowPosition = false;
- backMSG = true;
- }
- if(lastCall=="1" && trigger && isOutsideStadium && Math.abs(exitingPos - ballPosition.x)< throwInLeeway-20)
- {
- room.sendChat("OK");
- trigger = false;
- wrongThrowPosition = false;
- backMSG = true;
- }
- }
- function isThrowInCorrect()
- {
- var ballPosition = room.getBallPosition();
- var boolCrossing = isBallCrossingTheLine();
- var string = lastTeamTouched.toString();
- if(boolCrossing && !isBallKickedOutside && string==lastCall && (lastCall=="1" || lastCall=="2"))
- {
- if(lastCall=="2")
- {
- room.sendChat("RED (BAD THROW-IN)");
- }
- if(lastCall=="1")
- {
- room.sendChat("BLUE (BAD THROW-IN)");
- }
- isBallKickedOutside == false;
- }else if(boolCrossing && string!=lastCall && (lastCall=="1" || lastCall=="2"))
- {
- //room.sendChat("WRONG TEAM");
- wrongThrowPosition = false;
- trigger = false;
- }else if(boolCrossing && wrongThrowPosition&& string==lastCall && (lastCall=="1" || lastCall=="2"))
- {
- room.sendChat("WRONG PLACE");
- wrongThrowPosition = false;
- trigger = false;
- }else if(boolCrossing)
- {
- checkPlayersLine();
- }
- }
- function isBallCrossingTheLine()
- {
- previousBallPos = lineBallPosition;
- lineBallPosition = room.getBallPosition().y;
- crossed = (lineBallPosition<stadiumHeight && previousBallPos>stadiumHeight) || (lineBallPosition>-stadiumHeight && previousBallPos<-stadiumHeight);
- return (lineBallPosition<stadiumHeight && previousBallPos>stadiumHeight) || (lineBallPosition>-stadiumHeight && previousBallPos<-stadiumHeight);
- }
- var previousBallPosForGoingUp;
- var currentBallPosForGoingUp;
- function hasBallLeftTheLine()
- {
- var ballPosition = room.getBallPosition();
- if(ballPosition.y<outLineY && isBallKickedOutside)
- {
- }else if (ballPosition.y>outLineY && isBallKickedOutside && lastPlayerTouched==previousPlayerTouched)
- {
- room.sendChat("BAD THROW-IN");
- }
- }
- room.onStadiumChange = function(newStadiumName, byPlayer) {
- if (newStadiumName != "Real Soccer 1.3D by RawR") {
- room.setCustomStadium(RSHLMap);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement