Bot Ursa11-1
Bot Ursa11-1
Bot Ursa11-1
return realSoccerMap;
}
// ------------------------------------------------
// Global Variables
// ------------------------------------------------
var roomName = "🔵⚪ • 🔵 REAL SOCCER 4v4 URSA 🟡 • ⚪🔵"; //para cambiar el nombre
de la sala cambiar lo escrito entre las comillas ""
var roomPassword = null; //para poner contraseña a la sala pone "(contraseña)", si
no quieres contraseña deja (null)
var maxPlayers = 30;
var roomPublic = true; //para que la sala no aparezca en la lista de salas poner
(false), si quieres que aparezca pon (true)
// -------------------------------------------------
// Classes
// -------------------------------------------------
class Game {
constructor() {
this.ticks = 0;
this.time = 0;
this.active = true;
this.paused = false;
this.ballRadius;
this.rsTouchTeam = 0;
this.rsActive = true;
this.rsReady = false;
this.rsCorner = false;
this.rsGoalKick = false;
this.rsSwingTimer = 1000;
this.rsTimer;
this.ballOutPositionX;
this.ballOutPositionY;
this.throwInPosY;
this.outStatus = "";
this.warningCount = 0;
this.bringThrowBack = false;
this.extraTime = false;
this.extraTimeCount = 0;
this.extraTimeEnd;
this.extraTimeAnnounced = false;
this.lastPlayAnnounced = false;
this.boosterState;
this.throwinKicked = false;
this.pushedOut;
this.lastKickerId;
this.lastKickerName;
this.lastKickerTeam;
this.secondLastKickerId;
this.secondLastKickerName;
this.secondLastKickerTeam;
this.redScore = 0;
this.blueScore = 0;
}
this.lastKickerId = id;
this.lastKickerName = name;
this.lastKickerTeam = team;
}
}
room.setCustomStadium(getRealSoccerMap());
room.setScoreLimit(0);
room.setTimeLimit(10);
room.onRoomLink = function(url) {
roomLink = url;
console.log(roomLink);
}
room.onPlayerJoin = function(player) {
console.log(player.name + " joined the room");
whisper("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██╗░░░██╗██████╗░░██████╗░█████╗░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒", player.id, 0x82B3FB, "bold", 0);
whisper("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██║░░░██║██╔══██╗██╔════╝██╔══██╗▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒", player.id, 0x82B3FB, "bold", 0);
whisper("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██║░░░██║██████╔╝╚█████╗░███████║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒", player.id, 0xFFFFFF, "bold", 0);
whisper("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██║░░░██║██╔══██╗░╚═══██╗██╔══██║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒", player.id, 0xFFFFFF, "bold", 0);
whisper("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒╚██████╔╝██║░░██║██████╔╝██║░░██║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒", player.id, 0x82B3FB, "bold", 0);
whisper("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░╚═════╝░╚═╝░░╚═╝╚═════╝░╚═╝░░╚═╝▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒", player.id, 0x82B3FB, "bold", 0);
whisper("📢 Bienvenido al host oficial de la Unión de Real Soccer
Argentino", player.id, 0xFCBF49, "bold", 0);
whisper("📢 Discord oficial de la URSA: https://discord.gg/TrnZfVsEeN",
player.id, 0xFCBF49, "bold", 0);
displayAdminMessage();
room.onPlayerLeave = function(player) {
displayAdminMessage();
console.log(player.name + " salió del host");
}
room.onGameStart = function(byPlayer) {
if (map == "RSR") {
if (byPlayer == null) {
game = new Game();
announce("🕒 Tiempo de juego: " + gameTime + " minutos");
}
else {
if (room.getScores().timeLimit != 0) {
gameTime = room.getScores().timeLimit / 60;
}
else {
gameTime = 10;
}
room.stopGame();
room.setTimeLimit(0);
room.startGame();
}
}
}
room.onGameStop = function(byPlayer) {
if (map == "RSR") {
if (byPlayer == true) {
room.setTimeLimit(gameTime);
}
}
}
room.onPlayerBallKick = function(player) {
if (map == "RSR") {
game.rsTouchTeam = player.team;
game.updateLastKicker(player.id, player.name, player.team);
if (game.rsReady == true) {
var players = room.getPlayerList().filter((player) => player.team
!= 0);
players.forEach(function(player) {
if
(room.getPlayerDiscProperties(player.id).invMass.toFixed(1) != 0.3) {
room.setPlayerDiscProperties(player.id, {invMass:
0.3});
}
});
}
game.rsActive = true;
game.rsReady = false;
room.setDiscProperties(1, {x: 2000, y: 2000 });
room.setDiscProperties(2, {x: 2000, y: 2000 });
room.setDiscProperties(0, {color: "0xffffff"});
game.rsTimer = 1000000;
game.warningCount++;
game.rsCorner = false;
game.rsGoalKick = false;
game.outStatus = "";
}
room.onTeamGoal = function(team) {
if (map == "RSR") {
game.rsActive = false;
room.onPositionsReset = function() {
if (map == "RSR") {
if (game.lastPlayAnnounced == true) {
room.pauseGame(true);
game.lastPlayAnnounced = false;
announce("📢 Termino el partido!!");
}
}
}
room.onGameTick = function() {
if (map == "RSR") {
updateGameStatus();
handleBallTouch();
realSoccerRef();
}
}
function realSoccerRef() {
blockThrowIn();
blockGoalKick();
removeBlock();
if (game.time == gameTime * 60 && game.extraTimeAnnounced == false) {
extraTime();
game.extraTimeAnnounced = true;
}
if (game.rsTimer < 99999 && game.paused == false && game.rsActive == false &&
game.rsReady == true) {
game.rsTimer++;
}
if (game.boosterState == true) {
game.boosterCount++;
}
if (game.rsActive == true) {
if ((room.getBallPosition().y > 612 || room.getBallPosition().y < -
612)) {
game.rsActive = false;
if (game.lastPlayAnnounced == true) {
room.pauseGame(true);
game.lastPlayAnnounced = false;
announce("📢 Termino el partido!!");
}
});
sleep(100).then(() => {
room.setDiscProperties(3, {x: 0, y: 2000, radius:
0});
});
}
else {
room.setDiscProperties(3, {x: game.ballOutPositionX, y:
game.throwInPosY, radius: 18 });
sleep(100).then(() => {
game.outStatus = "redThrow";
game.throwinKicked = false;
game.rsTimer = 0;
game.rsReady = true;
room.setDiscProperties(0, {xspeed: 0, yspeed: 0, x:
game.ballOutPositionX, y: game.throwInPosY, xgravity: 0, ygravity: 0});
announce("🖐️ Lateral para: 🔴 Red");
room.setDiscProperties(0, {color: "0xff3f34"});
});
sleep(100).then(() => {
room.setDiscProperties(3, {x: 0, y: 2000, radius:
0});
});
}
}
if (game.rsTouchTeam == 1) {
room.setDiscProperties(3, {x: 1060, y: 0, radius: 18 });
sleep(100).then(() => {
game.outStatus = "blueGK";
game.rsTimer = 0;
game.rsReady = true;
announce("🥅 Saque de arco para: 🔵 Blue");
game.rsGoalKick = true;
game.rsSwingTimer = 0;
game.boosterCount = 0;
game.boosterState = false;
room.setDiscProperties(0, {xspeed: 0, yspeed: 0, x:
1060, y: 0, color: "0x0fbcf9", cMask: 268435519, xgravity: 0, ygravity: 0});
});
sleep(3000).then(() => {
room.setDiscProperties(3, {x: 0, y: 2000, radius:
0});
});
}
else {
announce("🚩 Corner para: 🔴 Red");
game.rsSwingTimer = 0;
if (room.getBallPosition().y < -124) {
room.setDiscProperties(3, {x: 1140, y: -590, radius:
18 });
sleep(100).then(() => {
game.rsCorner = true;
game.outStatus = "redCK";
game.rsTimer = 0;
game.rsReady = true;
game.boosterCount = 0;
game.boosterState = false;
room.setDiscProperties(0, {x: 1140, y: -590,
xspeed: 0, yspeed: 0, color: "0xff3f34", cMask: 268435519, xgravity: 0, ygravity:
0});
room.setDiscProperties(2, {x: 1150, y: -670,
radius: 420 });
room.setDiscProperties(3, {x: 0, y: 2000,
radius: 0});
});
}
if (room.getBallPosition().y > 124) {
room.setDiscProperties(3, {x: 1140, y: 590, radius:
18 });
sleep(100).then(() => {
game.rsCorner = true;
game.outStatus = "redCK";
game.rsTimer = 0;
game.rsReady = true;
game.boosterCount = 0;
game.boosterState = false;
room.setDiscProperties(0, {x: 1140, y: 590,
xspeed: 0, yspeed: 0, color: "0xff3f34", cMask: 268435519, xgravity: 0, ygravity:
0});
room.setDiscProperties(2, {x: 1150, y: 670,
radius: 420 });
room.setDiscProperties(3, {x: 0, y: 2000,
radius: 0});
});
}
}
}
if (room.getBallPosition().x < -1162 && (room.getBallPosition().y > 124
|| room.getBallPosition().y < -124)) {
game.rsActive = false;
if (game.lastPlayAnnounced == true) {
room.pauseGame(true);
game.lastPlayAnnounced = false;
announce("Fin");
}
room.setDiscProperties(0, {xgravity: 0, ygravity: 0});
room.getPlayerList().forEach(function(player) {
room.setPlayerDiscProperties(player.id, {invMass: 100000});
});
if (game.rsTouchTeam == 1) {
announce("🚩 Corner para: 🔵 Blue");
game.rsSwingTimer = 0;
if (room.getBallPosition().y < -124) {
room.setDiscProperties(3, {x: -1140, y: -590, radius:
18 });
sleep(100).then(() => {
game.rsCorner = true;
game.outStatus = "blueCK";
game.rsTimer = 0;
game.rsReady = true;
game.boosterCount = 0;
game.boosterState = false;
room.setDiscProperties(0, {x: -1140, y: -590,
xspeed: 0, yspeed: 0, color: "0x0fbcf9", cMask: 268435519, xgravity: 0, ygravity:
0});
room.setDiscProperties(1, {x: -1150, y: -670,
radius: 420 });
room.setDiscProperties(3, {x: 0, y: 2000,
radius: 0});
});
}
if (room.getBallPosition().y > 124) {
room.setDiscProperties(3, {x: -1140, y: 590, radius:
18 });
sleep(100).then(() => {
game.rsCorner = true;
game.outStatus = "blueCK";
game.rsTimer = 0;
game.rsReady = true;
game.boosterCount = 0;
game.boosterState = false;
room.setDiscProperties(0, {x: -1140, y: 590,
xspeed: 0, yspeed: 0, color: "0x0fbcf9", cMask: 268435519, xgravity: 0, ygravity:
0});
room.setDiscProperties(1, {x: -1150, y: 670,
radius: 420 });
room.setDiscProperties(3, {x: 0, y: 2000,
radius: 0});
});
}
}
else {
room.setDiscProperties(3, {x: -1060, y: 0, radius: 18 });
sleep(100).then(() => {
game.outStatus = "redGK";
game.rsTimer = 0;
game.rsReady = true;
announce("🥅 Saque de arco para: 🔴 Red");
game.rsGoalKick = true;
game.rsSwingTimer = 0;
game.boosterCount = 0;
game.boosterState = false;
room.setDiscProperties(0, {xspeed: 0, yspeed: 0, x: -
1060, y: 0, color: "0xff3f34", cMask: 268435519, xgravity: 0, ygravity: 0});
});
sleep(3000).then(() => {
room.setDiscProperties(3, {x: 0, y: 2000, radius:
0});
});
}
}
}
if (room.getBallPosition().y.toFixed(1) == game.throwInPosY.toFixed(1)
&& room.getBallPosition().x.toFixed(1) == game.ballOutPositionX.toFixed(1)) {
game.bringThrowBack = false;
game.pushedOut = false;
}
}
}
function handleBallTouch() {
var players = room.getPlayerList();
var ballPosition = room.getBallPosition();
var ballRadius = game.ballRadius;
var playerRadius = 15;
var triggerDistance = ballRadius + playerRadius + 0.01;
for (var i = 0; i < players.length; i++) { // Iterate over all the players
var player = players[i];
if ( player.position == null ) continue;
var distanceToBall = pointDistance(player.position, ballPosition);
if ( distanceToBall < triggerDistance ) {
game.rsTouchTeam = player.team;
game.throwinKicked = false;
function updateGameStatus() {
game.time = Math.floor(room.getScores().time);
game.ballRadius = room.getDiscProperties(0).radius;
game.ticks++;
}
function isAdminPresent() {
var players = room.getPlayerList();
if (players.find((player) => player.admin) != null) {
return true;
}
else {
return false;
}
}
function displayAdminMessage() {
if (isAdminPresent() == false) {
announce("📢 No hay admin presente: escribe !admin");
}
}
function extraTime() {
var extraSeconds = Math.ceil(game.extraTimeCount / 60);
game.extraTimeEnd = (gameTime * 60) + extraSeconds;
announce("📢 Tiempo agregado: " + extraSeconds + " Segundos", null, null,
null, 1);
}
function secondsToMinutes(time) {
// Hours, minutes and seconds
var hrs = ~~(time / 3600);
var mins = ~~((time % 3600) / 60);
var secs = ~~time % 60;
function blockThrowIn() {
var players = room.getPlayerList().filter((player) => player.team != 0);
if (room.getBallPosition().y < 0) { // top throw line
if (game.outStatus == "redThrow") {
players.forEach(function(player) {
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).y < 0) {
if (room.getPlayerDiscProperties(player.id).cGroup !=
536870918) {
room.setPlayerDiscProperties(player.id,
{cGroup: 536870918});
}
if (player.position.y < -485) {
room.setPlayerDiscProperties(player.id, {y: -
470});
}
}
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
if (room.getDiscProperties(17).x != 1149) { // show top red
line
room.setDiscProperties(17, {x: 1149});
}
if (room.getDiscProperties(19).x != -1149) { // hide top
blue line
room.setDiscProperties(19, {x: -1149});
}
});
}
if (game.outStatus == "blueThrow") {
players.forEach(function(player) {
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).y < 0) {
if (room.getPlayerDiscProperties(player.id).cGroup !=
536870918) {
room.setPlayerDiscProperties(player.id,
{cGroup: 536870918});
}
if (player.position.y < -485) {
room.setPlayerDiscProperties(player.id, {y: -
470});
}
}
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
if (room.getDiscProperties(19).x != 1149) { // show top
blue line
room.setDiscProperties(19, {x: 1149});
}
if (room.getDiscProperties(17).x != -1149) { // hide top
red line
room.setDiscProperties(17, {x: -1149});
}
});
}
}
if (room.getBallPosition().y > 0) { // bottom throw line
if (game.outStatus == "redThrow") {
players.forEach(function(player) {
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).y > 0) {
if (room.getPlayerDiscProperties(player.id).cGroup !=
536870918) {
room.setPlayerDiscProperties(player.id,
{cGroup: 536870918});
}
if (player.position.y > 485) {
room.setPlayerDiscProperties(player.id, {y:
470});
}
}
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
if (room.getDiscProperties(21).x != 1149) { // show bottom
red line
room.setDiscProperties(21, {x: 1149});
}
if (room.getDiscProperties(23).x != -1149) { // hide bottom
blue line
room.setDiscProperties(23, {x: -1149});
}
});
}
if (game.outStatus == "blueThrow") {
players.forEach(function(player) {
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).y > 0) {
if (room.getPlayerDiscProperties(player.id).cGroup !=
536870918) {
room.setPlayerDiscProperties(player.id,
{cGroup: 536870918});
}
if (player.position.y > 485) {
room.setPlayerDiscProperties(player.id, {y:
470});
}
}
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
if (room.getDiscProperties(23).x != 1149) { // show bottom
blue line
room.setDiscProperties(23, {x: 1149});
}
if (room.getDiscProperties(21).x != -1149) { // hide bottom
red line
room.setDiscProperties(21, {x: -1149});
}
});
}
}
}
function blockGoalKick() {
var players = room.getPlayerList().filter((player) => player.team != 0);
if (room.getBallPosition().x < 0) { // left side red goal kick
if (game.outStatus == "redGK") {
players.forEach(function(player) {
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).x < 0) {
if (room.getPlayerDiscProperties(player.id).cGroup !=
268435462) {
room.setPlayerDiscProperties(player.id,
{cGroup: 268435462});
}
if (player.position.x < -840 && player.position.y > -
320 && player.position.y < 320) {
room.setPlayerDiscProperties(player.id, {x: -
825});
}
}
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
});
}
}
if (room.getBallPosition().x > 0) { // right side blue goal kick
if (game.outStatus == "blueGK") {
players.forEach(function(player) {
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).x > 0) {
if (room.getPlayerDiscProperties(player.id).cGroup !=
268435462) {
room.setPlayerDiscProperties(player.id,
{cGroup: 268435462});
}
if (player.position.x > 840 && player.position.y > -
320 && player.position.y < 320) {
room.setPlayerDiscProperties(player.id, {x:
825});
}
}
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
});
}
}
}
function removeBlock() {
var players = room.getPlayerList().filter((player) => player.team != 0);
if (game.outStatus == "") {
players.forEach(function(player) {
if (player.team == 1 &&
room.getPlayerDiscProperties(player.id).cGroup != 2) {
room.setPlayerDiscProperties(player.id, {cGroup: 2});
}
if (player.team == 2 &&
room.getPlayerDiscProperties(player.id).cGroup != 4) {
room.setPlayerDiscProperties(player.id, {cGroup: 4});
}
});
if (room.getDiscProperties(17).x != -1149) { // hide top red line
room.setDiscProperties(17, {x: -1149});
}
if (room.getDiscProperties(19).x != -1149) { // hide top blue line
room.setDiscProperties(19, {x: -1149});
}
if (room.getDiscProperties(21).x != -1149) { // hide bottom red line
room.setDiscProperties(21, {x: -1149});
}
if (room.getDiscProperties(23).x != -1149) { // hide bottom blue line
room.setDiscProperties(23, {x: -1149});
}
}
}
function rfc3986EncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
}