-
-
Save nabbynz/263af1f8f295326a500df883a00e10f1 to your computer and use it in GitHub Desktop.
My Ball Is Different
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name My Ball Is Different | |
// @description Changes your ball texture | |
// @version 0.0.1 | |
// @include http://tagpro-*.koalabeast.com:* | |
// @include http://tagpro-test.koalabeast.com/game | |
// @updateURL https://gist.github.com/nabbynz/263af1f8f295326a500df883a00e10f1/raw/My_Ball_Is_Different.user.js | |
// @downloadURL https://gist.github.com/nabbynz/263af1f8f295326a500df883a00e10f1/raw/My_Ball_Is_Different.user.js | |
// @grant none | |
// @author nabby | |
// ==/UserScript== | |
console.log('START: ' + GM_info.script.name + ' (v' + GM_info.script.version + ' by ' + GM_info.script.author + ')'); | |
tagpro.ready(function() { | |
let tr = tagpro.renderer; | |
function makeMyBallTextures() { | |
if (!PIXI.utils.TextureCache.myredball) { | |
let red, blue, redball, blueball; | |
let x = 560; | |
let y = 360; | |
if (!PIXI.utils.BaseTextureCache[tagpro.tiles.image.src]) { | |
let tilesTexture = new PIXI.Texture.from(tagpro.tiles.image); | |
PIXI.Texture.addToCache(tilesTexture, tagpro.tiles.image.src); | |
} | |
red = new PIXI.Rectangle(x, y, 40, 40); | |
blue = new PIXI.Rectangle(x+40, y, 40, 40); | |
myredball = new PIXI.Texture(PIXI.utils.BaseTextureCache[tagpro.tiles.image.src], red); | |
myblueball = new PIXI.Texture(PIXI.utils.BaseTextureCache[tagpro.tiles.image.src], blue); | |
PIXI.utils.TextureCache.myredball = myredball; | |
PIXI.utils.TextureCache.myblueball = myblueball; | |
} | |
if (tagpro.players[tagpro.playerId].sprites.hasOwnProperty('actualBall')) { | |
let tileId = tagpro.players[tagpro.playerId].team === 1 ? "myredball" : "myblueball"; | |
let baseTexture = tagpro.tiles.getTexture(tileId); | |
tagpro.players[tagpro.playerId].sprites.actualBall.texture = baseTexture; | |
} | |
} | |
setTimeout(function() { | |
makeMyBallTextures(); | |
tr.updatePlayerColor = function(player) { | |
let tileId = player.team === 1 ? "redball" : "blueball"; | |
if (player.sprites.actualBall.tileId !== tileId) { | |
let baseTexture = tagpro.tiles.getTexture(player.id == tagpro.playerId ? (player.team === 1 ? "myredball" : "myblueball") : tileId); | |
player.sprites.actualBall.texture = baseTexture; | |
player.sprites.actualBall.tileId = tileId; | |
} | |
}; | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment