Guest User

Untitled

a guest
Dec 13th, 2025
3,894
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.16 KB | None | 0 0
  1. // ==UserScript==
  2. // @name ZA Sprites
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-10-19
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://play.pokemonshowdown.com/*
  8. // @match https://smogtours.psim.us/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=pokemonshowdown.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14. (function () {
  15. 'use strict';
  16. const ZA_DLC_MEGAS = {
  17. 'absolmegaz': {
  18. fn: 'https://i.ibb.co/xKPzs3Px/image.png',
  19. fs: 'https://i.ibb.co/xKPzs3Px/image.png',
  20. },
  21. 'baxcaliburmega': {
  22. fn: 'https://i.ibb.co/6R27njjB/image.png',
  23. fs: 'https://i.ibb.co/6R27njjB/image.png',
  24. },
  25. 'chimechomega': {
  26. fn: 'https://i.ibb.co/xrtV2JY/image.png',
  27. fs: 'https://i.ibb.co/xrtV2JY/image.png',
  28. },
  29. 'crabominablemega': {
  30. fn: 'https://i.ibb.co/xttc6Fz5/image.png',
  31. fs: 'https://i.ibb.co/xttc6Fz5/image.png',
  32. },
  33. 'darkraimega': {
  34. fn: 'https://i.ibb.co/c9LBMhb/image.png',
  35. fs: 'https://i.ibb.co/c9LBMhb/image.png',
  36. },
  37. 'garchompmegaz': {
  38. fn: 'https://i.ibb.co/Z1NqzRXc/image.png',
  39. fs: 'https://i.ibb.co/Z1NqzRXc/image.png',
  40. },
  41. 'glimmoramega': {
  42. fn: 'https://i.ibb.co/4R1BXZMj/image.png',
  43. fs: 'https://i.ibb.co/4R1BXZMj/image.png',
  44. },
  45. 'golisopodmega': {
  46. fn: 'https://i.ibb.co/LX2R85wn/image.png',
  47. fs: 'https://i.ibb.co/LX2R85wn/image.png',
  48. },
  49. 'golurkmega': {
  50. fn: 'https://i.ibb.co/0Tcr7yz/image.png',
  51. fs: 'https://i.ibb.co/0Tcr7yz/image.png',
  52. },
  53. 'heatranmega': {
  54. fn: 'https://i.ibb.co/Y76mqL1z/image.png',
  55. fs: 'https://i.ibb.co/Y76mqL1z/image.png',
  56. },
  57. 'lucariomegaz': {
  58. fn: 'https://i.ibb.co/HpBtyjqY/image.png',
  59. fs: 'https://i.ibb.co/HpBtyjqY/image.png',
  60. },
  61. 'magearnamega': {
  62. fn: 'https://i.ibb.co/7xQTPvgj/image.png',
  63. fs: 'https://i.ibb.co/7xQTPvgj/image.png',
  64. },
  65. 'meowsticfmega': {
  66. fn: 'https://i.ibb.co/GbsYmXm/image.png',
  67. fs: 'https://i.ibb.co/GbsYmXm/image.png',
  68. },
  69. 'raichumegax': {
  70. fn: 'https://i.ibb.co/jkLGNV5x/image.png',
  71. fs: 'https://i.ibb.co/jkLGNV5x/image.png',
  72. },
  73. 'raichumegay': {
  74. fn: 'https://i.ibb.co/PvcW5Dtd/image.png',
  75. fs: 'https://i.ibb.co/PvcW5Dtd/image.png',
  76. },
  77. 'scovillainmega': {
  78. fn: 'https://i.ibb.co/BvzYDf6/image.png',
  79. fs: 'https://i.ibb.co/BvzYDf6/image.png',
  80. },
  81. 'staraptormega': {
  82. fn: 'https://i.ibb.co/351DPXgg/image.png',
  83. fs: 'https://i.ibb.co/351DPXgg/image.png',
  84. },
  85. 'tatsugiricurlymega': {
  86. fn: 'https://i.ibb.co/QvVG1MWn/image.png',
  87. fs: 'https://i.ibb.co/QvVG1MWn/image.png',
  88. },
  89. 'zeraoramega': {
  90. fn: 'https://i.ibb.co/Ps8BKPyy/image.png',
  91. fs: 'https://i.ibb.co/Ps8BKPyy/image.png',
  92. },
  93. };
  94. const ZA_MEGAS = {
  95. // Sprites by KingOfThe-X-Road (https://x.com/kingofthexroad5)
  96. // 'clefablemega': {
  97. // fn: 'https://i.ibb.co/mCMWRCdY/image.png',
  98. // fs: 'https://i.ibb.co/pBVM5Qg8/image.png'
  99. // },
  100. // 'victreebelmega': {
  101. // fn: 'https://i.ibb.co/60vfrDJm/image.png',
  102. // fs: 'https://i.ibb.co/vCQ8Tz3w/image.png',
  103. // bn: 'https://i.ibb.co/8g3XvtNd/image.png',
  104. // bs: 'https://i.ibb.co/wrZNgMfC/image.png'
  105. // },
  106. // 'starmiemega': {
  107. // fn: 'https://i.ibb.co/cKB0ZQbZ/image.png',
  108. // fs: 'https://i.ibb.co/jvRSD4S6/image.png'
  109. // },
  110. // 'meganiummega': {
  111. // fn: 'https://i.ibb.co/0RYrbv2X/image.png',
  112. // fs: 'https://i.ibb.co/mCJqzyBy/image.png'
  113. // },
  114. // 'feraligatrmega': {
  115. // fn: 'https://i.ibb.co/Z6CPZ9W7/image.png',
  116. // fs: 'https://i.ibb.co/dwKnw27P/image.png'
  117. // },
  118. // 'skarmorymega': {
  119. // fn: 'https://i.ibb.co/zh15Qq2x/image.png',
  120. // fs: 'https://i.ibb.co/hx484z2c/image.png'
  121. // },
  122. // 'froslassmega': {
  123. // fn: 'https://i.ibb.co/LzGPJwJS/image.png',
  124. // fs: 'https://i.ibb.co/qY5CsgL2/image.png'
  125. // },
  126. // 'emboarmega': {
  127. // fn: 'https://i.ibb.co/rK0HNbPM/image.png',
  128. // fs: 'https://i.ibb.co/fY4k0tTY/image.png'
  129. // },
  130. 'excadrillmega': {
  131. fn: 'https://i.ibb.co/yBpjCRxc/image.png',
  132. fs: 'https://i.ibb.co/cXrj0qDx/image.png'
  133. },
  134. 'scolipedemega': {
  135. fn: 'https://i.ibb.co/rKNq4Jnv/image.png',
  136. fs: 'https://i.ibb.co/jv1nnVvj/image.png'
  137. },
  138. 'scraftymega': {
  139. fn: 'https://i.ibb.co/LXHsYBWn/image.png',
  140. fs: 'https://i.ibb.co/svZc9mL2/image.png'
  141. },
  142. 'eelektrossmega': {
  143. fn: 'https://i.ibb.co/ZprhFc3K/image.png',
  144. fs: 'https://i.ibb.co/tgFrDvn/image.png',
  145. },
  146. 'chandeluremega': {
  147. fn: 'https://i.ibb.co/mFD6477w/image.png',
  148. fs: 'https://i.ibb.co/b5jQs8hh/image.png'
  149. },
  150. 'chesnaughtmega': {
  151. fn: 'https://i.ibb.co/tPk4rN91/image.png'
  152. },
  153. 'delphoxmega': {
  154. fn: 'https://i.ibb.co/mFGfvBWc/image.png'
  155. },
  156. 'greninjamega': {
  157. fn: 'https://i.ibb.co/zTQZF0zg/image.png'
  158. },
  159. 'pyroarmega': {
  160. fn: 'https://i.ibb.co/6RcQMnGr/image.png',
  161. fs: 'https://i.ibb.co/Jwcn0c9w/image.png',
  162. },
  163. 'floettemega': {
  164. fn: 'https://i.ibb.co/RTqf9vw8/image.png',
  165. fs: 'https://i.ibb.co/4xqDJt8/image.png'
  166. },
  167. 'malamarmega': {
  168. fn: 'https://i.ibb.co/hFdCQTdN/image.png',
  169. bn: 'https://i.ibb.co/hF7MR2VT/image.png'
  170. },
  171. 'barbaraclemega': {
  172. fn: 'https://i.ibb.co/WNcps5Sv/image.png',
  173. fs: 'https://i.ibb.co/rK9bmCZw/image.png'
  174. },
  175. 'dragalgemega': {
  176. fn: 'https://i.ibb.co/849Pcfhn/image.png',
  177. fs: 'https://i.ibb.co/hRwTCRNS/image.png'
  178. },
  179. 'hawluchamega': {
  180. fn: 'https://i.ibb.co/HT27Mypv/image.png',
  181. fs: 'https://i.ibb.co/8nRN9krW/image.png',
  182. bn: 'https://i.ibb.co/53tBqGj/image.png',
  183. bs: 'https://i.ibb.co/YBWZspjz/image.png'
  184. },
  185. 'zygardemega': {
  186. fn: 'https://i.ibb.co/Wv29jpt8/image.png',
  187. fs: 'https://i.ibb.co/p65J1nZy/image.png'
  188. },
  189. 'drampamega': {
  190. fn: 'https://i.ibb.co/TySjQy6/image.png',
  191. fs: 'https://i.ibb.co/m5fp6Rfr/image.png'
  192. },
  193. 'falinksmega': {
  194. fn: 'https://i.ibb.co/sJvxDq67/image.png',
  195. fs: 'https://i.ibb.co/qLh6n38J/image.png'
  196. }
  197. };
  198. Dex.getSpriteData = function (pokemon, isFront, options = { gen: 6 }) {
  199. const mechanicsGen = options.gen || 6;
  200. let isDynamax = !!options.dynamax;
  201. if (pokemon instanceof Pokemon) {
  202. if (pokemon.volatiles.transform) {
  203. options.shiny = pokemon.volatiles.transform[2];
  204. options.gender = pokemon.volatiles.transform[3];
  205. } else {
  206. options.shiny = pokemon.shiny;
  207. options.gender = pokemon.gender;
  208. }
  209. let isGigantamax = false;
  210. if (pokemon.volatiles.dynamax) {
  211. if (pokemon.volatiles.dynamax[1]) {
  212. isGigantamax = true;
  213. } else if (options.dynamax !== false) {
  214. isDynamax = true;
  215. }
  216. }
  217. pokemon = pokemon.getSpeciesForme() + (isGigantamax ? '-Gmax' : '');
  218. }
  219. const species = Dex.species.get(pokemon);
  220. // Gmax sprites are already extremely large, so we don't need to double.
  221. if (species.name.endsWith('-Gmax')) isDynamax = false;
  222. let spriteData = {
  223. gen: mechanicsGen,
  224. w: 96,
  225. h: 96,
  226. y: 0,
  227. url: Dex.resourcePrefix + 'sprites/',
  228. pixelated: true,
  229. isFrontSprite: false,
  230. cryurl: '',
  231. shiny: options.shiny,
  232. };
  233. let name = species.spriteid;
  234. let dir;
  235. let facing;
  236. if (isFront) {
  237. spriteData.isFrontSprite = true;
  238. dir = '';
  239. facing = 'front';
  240. } else {
  241. dir = '-back';
  242. facing = 'back';
  243. }
  244.  
  245. // Decide which gen sprites to use.
  246. //
  247. // There are several different generations we care about here:
  248. //
  249. // - mechanicsGen: the generation number of the mechanics and battle (options.gen)
  250. // - graphicsGen: the generation number of sprite/field graphics the user has requested.
  251. // This will default to mechanicsGen, but may be altered depending on user preferences.
  252. // - spriteData.gen: the generation number of a the specific Pokemon sprite in question.
  253. // This defaults to graphicsGen, but if the graphicsGen doesn't have a sprite for the Pokemon
  254. // (eg. Darmanitan in graphicsGen 2) then we go up gens until it exists.
  255. //
  256. let graphicsGen = mechanicsGen;
  257. if (Dex.prefs('nopastgens')) graphicsGen = 6;
  258. if (Dex.prefs('bwgfx') && graphicsGen >= 6) graphicsGen = 5;
  259. spriteData.gen = Math.max(graphicsGen, Math.min(species.gen, 5));
  260. const baseDir = ['', 'gen1', 'gen2', 'gen3', 'gen4', 'gen5', '', '', '', ''][spriteData.gen];
  261.  
  262. let miscData = null;
  263. let speciesid = species.id;
  264. if (species.isTotem) speciesid = toID(name);
  265. if (window.BattlePokemonSprites) miscData = BattlePokemonSprites[speciesid];
  266. if (!miscData && window.BattlePokemonSpritesBW) miscData = BattlePokemonSpritesBW[speciesid];
  267. if (!miscData) miscData = {};
  268.  
  269. if (miscData.num !== 0 && miscData.num > -5000) {
  270. let baseSpeciesid = toID(species.baseSpecies);
  271. spriteData.cryurl = 'audio/cries/' + baseSpeciesid;
  272. let formeid = species.formeid;
  273. if (species.isMega || formeid && (
  274. formeid === '-crowned' ||
  275. formeid === '-eternal' ||
  276. formeid === '-eternamax' ||
  277. formeid === '-four' ||
  278. formeid === '-hangry' ||
  279. formeid === '-hero' ||
  280. formeid === '-lowkey' ||
  281. formeid === '-noice' ||
  282. formeid === '-primal' ||
  283. formeid === '-rapidstrike' ||
  284. formeid === '-roaming' ||
  285. formeid === '-school' ||
  286. formeid === '-sky' ||
  287. formeid === '-starter' ||
  288. formeid === '-super' ||
  289. formeid === '-therian' ||
  290. formeid === '-unbound' ||
  291. baseSpeciesid === 'calyrex' ||
  292. baseSpeciesid === 'kyurem' ||
  293. baseSpeciesid === 'cramorant' ||
  294. baseSpeciesid === 'indeedee' ||
  295. baseSpeciesid === 'lycanroc' ||
  296. baseSpeciesid === 'necrozma' ||
  297. baseSpeciesid === 'oinkologne' ||
  298. baseSpeciesid === 'oricorio' ||
  299. baseSpeciesid === 'slowpoke' ||
  300. baseSpeciesid === 'tatsugiri' ||
  301. baseSpeciesid === 'zygarde'
  302. )) {
  303. spriteData.cryurl += formeid;
  304. }
  305. spriteData.cryurl += '.mp3';
  306. }
  307.  
  308. if (options.shiny && mechanicsGen > 1) dir += '-shiny';
  309.  
  310. // April Fool's 2014
  311. if (Dex.afdMode || options.afd) {
  312. // Explicit false check above means AFD will be off if the user disables it - no matter what
  313. dir = 'afd' + dir;
  314. spriteData.url += dir + '/' + name + '.png';
  315. // Duplicate code but needed to make AFD tinymax work
  316. // April Fool's 2020
  317. if (isDynamax && !options.noScale) {
  318. spriteData.w *= 0.25;
  319. spriteData.h *= 0.25;
  320. spriteData.y += -22;
  321. } else if (species.isTotem && !options.noScale) {
  322. spriteData.w *= 0.5;
  323. spriteData.h *= 0.5;
  324. spriteData.y += -11;
  325. }
  326. return spriteData;
  327. }
  328.  
  329. // Mod Cries
  330. if (options.mod) {
  331. spriteData.cryurl = `sprites/${options.mod}/audio/${toID(species.baseSpecies)}`;
  332. spriteData.cryurl += '.mp3';
  333. }
  334.  
  335. let animatedSprite = false;
  336. if (!Dex.prefs('noanim') && !Dex.prefs('nogif') && spriteData.gen >= 5) {
  337. const animationArray = [];
  338. if (baseDir === '' && window.BattlePokemonSprites) {
  339. animationArray.push([BattlePokemonSprites[speciesid], '']);
  340. }
  341. if (window.BattlePokemonSpritesBW) {
  342. animationArray.push([BattlePokemonSpritesBW[speciesid], 'gen5']);
  343. }
  344. for (const [animationData, animDir] of animationArray) {
  345. if (!animationData) continue;
  346. if (animationData[facing + 'f'] && options.gender === 'F') facing += 'f';
  347. if (!animationData[facing]) continue;
  348. if (facing.endsWith('f')) name += '-f';
  349. if (spriteData.gen >= 6) spriteData.pixelated = false;
  350. dir = animDir + 'ani' + dir;
  351. spriteData.w = animationData[facing].w;
  352. spriteData.h = animationData[facing].h;
  353. spriteData.url += dir + '/' + name + '.gif';
  354. animatedSprite = true;
  355. break;
  356. }
  357. }
  358. if (!animatedSprite) {
  359. // There is no entry or enough data in pokedex-mini.js
  360. // Handle these in case-by-case basis; either using BW sprites or matching the played gen.
  361. dir = (baseDir || 'gen5') + dir;
  362.  
  363. // Gender differences don't exist prior to Gen 4,
  364. // so there are no sprites for it
  365. if (spriteData.gen >= 4 && miscData['frontf'] && options.gender === 'F') {
  366. name += '-f';
  367. }
  368.  
  369. spriteData.url += dir + '/' + name + '.png';
  370. }
  371.  
  372. if (!options.noScale) {
  373. if (graphicsGen > 4) {
  374. // no scaling
  375. } else if (spriteData.isFrontSprite) {
  376. spriteData.w *= 2;
  377. spriteData.h *= 2;
  378. spriteData.y += -16;
  379. } else {
  380. // old gen backsprites are multiplied by 1.5x by the 3D engine
  381. spriteData.w *= 2 / 1.5;
  382. spriteData.h *= 2 / 1.5;
  383. spriteData.y += -11;
  384. }
  385. if (spriteData.gen <= 2) spriteData.y += 2;
  386. }
  387. if (isDynamax && !options.noScale) {
  388. spriteData.w *= 2;
  389. spriteData.h *= 2;
  390. spriteData.y += -22;
  391. } else if (species.isTotem && !options.noScale) {
  392. spriteData.w *= 1.5;
  393. spriteData.h *= 1.5;
  394. spriteData.y += -11;
  395. }
  396. if (ZA_DLC_MEGAS[species.id]) {
  397. const key = (isFront ? "f" : "b") + (options.shiny ? "s" : "n");
  398. spriteData.url = ZA_DLC_MEGAS[species.id][key] || ZA_DLC_MEGAS[species.id]["fn"];
  399. }
  400. if (ZA_MEGAS[species.id]) {
  401. const key = (isFront ? "f" : "b") + (options.shiny ? "s" : "n");
  402. spriteData.url = ZA_MEGAS[species.id][key] || ZA_MEGAS[species.id]["fn"];
  403. }
  404. return spriteData;
  405. }
  406. BattleTooltips.prototype.showPokemonTooltip = function (
  407. clientPokemon, serverPokemon, isActive, illusionIndex
  408. ) {
  409. const pokemon = clientPokemon || serverPokemon;
  410. let text = '';
  411. let genderBuf = '';
  412. const gender = pokemon.gender;
  413. if (gender === 'M' || gender === 'F') {
  414. genderBuf = ` <img src="${Dex.fxPrefix}gender-${gender.toLowerCase()}.png" alt="${gender}" width="7" height="10" class="pixelated" /> `;
  415. }
  416.  
  417. const ignoreNicks = this.battle.ignoreNicks || this.battle.ignoreOpponent;
  418. const nickname = ignoreNicks ? Dex.species.get(pokemon.speciesForme).baseSpecies : pokemon.name;
  419. let name = BattleLog.escapeHTML(nickname);
  420. if (pokemon.speciesForme !== nickname) {
  421. name += ` <small>(${BattleLog.escapeHTML(pokemon.speciesForme)})</small>`;
  422. }
  423.  
  424. let levelBuf = (pokemon.level !== 100 ? ` <small>L${pokemon.level}</small>` : ``);
  425. if (!illusionIndex || illusionIndex === 1) {
  426. text += `<h2>${name}${genderBuf}${illusionIndex ? '' : levelBuf}<br />`;
  427.  
  428. if (clientPokemon?.volatiles.formechange) {
  429. if (clientPokemon.volatiles.transform) {
  430. text += `<small>(Transformed into ${clientPokemon.volatiles.formechange[1]})</small><br />`;
  431. } else {
  432. text += `<small>(Changed forme: ${clientPokemon.volatiles.formechange[1]})</small><br />`;
  433. }
  434. }
  435.  
  436. let types = serverPokemon?.terastallized ? [serverPokemon.teraType] : this.getPokemonTypes(pokemon);
  437. let knownPokemon = serverPokemon || clientPokemon;
  438.  
  439. if (pokemon.terastallized) {
  440. text += `<small>(Terastallized)</small><br />`;
  441. } else if (clientPokemon?.volatiles.typechange || clientPokemon?.volatiles.typeadd) {
  442. text += `<small>(Type changed)</small><br />`;
  443. }
  444. text += `<span class="textaligned-typeicons">${types.map(type => Dex.getTypeIcon(type)).join(' ')}</span>`;
  445. if (pokemon.terastallized) {
  446. text += `&nbsp; &nbsp; <small>(base: <span class="textaligned-typeicons">${this.getPokemonTypes(pokemon, true).map(type => Dex.getTypeIcon(type)).join(' ')}</span>)</small>`;
  447. } else if (knownPokemon.teraType && !this.battle.rules['Terastal Clause']) {
  448. text += `&nbsp; &nbsp; <small>(Tera Type: <span class="textaligned-typeicons">${Dex.getTypeIcon(knownPokemon.teraType)}</span>)</small>`;
  449. }
  450. text += `</h2>`;
  451. }
  452.  
  453. if (illusionIndex) {
  454. text += `<p class="tooltip-section"><strong>Possible Illusion #${illusionIndex}</strong>${levelBuf}</p>`;
  455. }
  456.  
  457. if (pokemon.fainted) {
  458. text += '<p><small>HP:</small> (fainted)</p>';
  459. } else if (this.battle.hardcoreMode) {
  460. if (serverPokemon) {
  461. const status = pokemon.status ? ` <span class="status ${pokemon.status}">${pokemon.status.toUpperCase()}</span>` : '';
  462. text += `<p><small>HP:</small> ${serverPokemon.hp}/${serverPokemon.maxhp}${status}</p>`;
  463. }
  464. } else {
  465. let exacthp = '';
  466. if (serverPokemon) {
  467. exacthp = ` (${serverPokemon.hp}/${serverPokemon.maxhp})`;
  468. } else if (pokemon.maxhp === 48) {
  469. exacthp = ` <small>(${pokemon.hp}/${pokemon.maxhp} pixels)</small>`;
  470. }
  471. const status = pokemon.status ? ` <span class="status ${pokemon.status}">${pokemon.status.toUpperCase()}</span>` : '';
  472. text += `<p><small>HP:</small> ${Pokemon.getHPText(pokemon, this.battle.reportExactHP)}${exacthp}${status}`;
  473. if (clientPokemon) {
  474. if (pokemon.status === 'tox') {
  475. if (pokemon.ability === 'Poison Heal' || pokemon.ability === 'Magic Guard') {
  476. text += ` <small>Would take if ability removed: ${Math.floor(
  477. 100 / 16 * Math.min(clientPokemon.statusData.toxicTurns + 1, 15)
  478. )}%</small>`;
  479. } else {
  480. text += ` Next damage: ${Math.floor(
  481. 100 / (clientPokemon.volatiles['dynamax'] ? 32 : 16) * Math.min(clientPokemon.statusData.toxicTurns + 1, 15)
  482. )}%`;
  483. }
  484. } else if (pokemon.status === 'slp') {
  485. text += ` Turns asleep: ${clientPokemon.statusData.sleepTurns}`;
  486. }
  487. }
  488. text += '</p>';
  489. }
  490.  
  491. const supportsAbilities = this.battle.gen > 2 && !this.battle.tier.includes("Let's Go");
  492.  
  493. let abilityText = '';
  494. if (supportsAbilities) {
  495. abilityText = this.getPokemonAbilityText(
  496. clientPokemon, serverPokemon, isActive, !!illusionIndex && illusionIndex > 1
  497. );
  498. }
  499.  
  500. let itemText = '';
  501. if (serverPokemon) {
  502. let item = '';
  503. let itemEffect = '';
  504. if (clientPokemon?.prevItem) {
  505. item = 'None';
  506. let prevItem = this.battle.dex.items.get(clientPokemon.prevItem).name;
  507. itemEffect += clientPokemon.prevItemEffect ? prevItem + ' was ' + clientPokemon.prevItemEffect : 'was ' + prevItem;
  508. }
  509. if (serverPokemon.item) item = this.battle.dex.items.get(serverPokemon.item).name;
  510. if (itemEffect) itemEffect = ' (' + itemEffect + ')';
  511. if (item) itemText = '<small>Item:</small> ' + item + itemEffect;
  512. } else if (clientPokemon) {
  513. let item = '';
  514. let itemEffect = clientPokemon.itemEffect || '';
  515. if (clientPokemon.prevItem) {
  516. item = 'None';
  517. if (itemEffect) itemEffect += '; ';
  518. let prevItem = this.battle.dex.items.get(clientPokemon.prevItem).name;
  519. itemEffect += clientPokemon.prevItemEffect ? prevItem + ' was ' + clientPokemon.prevItemEffect : 'was ' + prevItem;
  520. }
  521. if (pokemon.item) item = this.battle.dex.items.get(pokemon.item).name;
  522. if (itemEffect) itemEffect = ' (' + itemEffect + ')';
  523. if (item) itemText = '<small>Item:</small> ' + item + itemEffect;
  524. }
  525.  
  526. if (abilityText || itemText) {
  527. text += '<p>';
  528. text += abilityText;
  529. if (abilityText && itemText) {
  530. // ability/item on one line for your own switch tooltips, two lines everywhere else
  531. text += (!isActive && serverPokemon ? ' / ' : '</p><p>');
  532. }
  533. text += itemText;
  534. text += '</p>';
  535. }
  536.  
  537. text += this.renderStats(clientPokemon, serverPokemon, !isActive);
  538.  
  539. if (serverPokemon && !isActive) {
  540. // move list
  541. text += `<p class="tooltip-section">`;
  542. const battlePokemon = clientPokemon || this.battle.findCorrespondingPokemon(pokemon);
  543. for (const moveid of serverPokemon.moves) {
  544. const move = this.battle.dex.moves.get(moveid);
  545. let moveName = `&#8226; ${move.name}`;
  546. if (battlePokemon?.moveTrack) {
  547. for (const row of battlePokemon.moveTrack) {
  548. if (moveName === row[0]) {
  549. moveName = this.getPPUseText(row, true);
  550. break;
  551. }
  552. }
  553. }
  554. text += `${moveName}<br />`;
  555. }
  556. text += '</p>';
  557. } else if (!this.battle.hardcoreMode && clientPokemon?.moveTrack.length) {
  558. // move list (guessed)
  559. text += `<p class="tooltip-section">`;
  560. for (const row of clientPokemon.moveTrack) {
  561. text += `${this.getPPUseText(row)}<br />`;
  562. }
  563. if (clientPokemon.moveTrack.filter(([moveName]) => {
  564. if (moveName.startsWith('*')) return false;
  565. const move = this.battle.dex.moves.get(moveName);
  566. return !move.isZ && !move.isMax && move.name !== 'Mimic';
  567. }).length > 4) {
  568. text += `(More than 4 moves is usually a sign of Illusion Zoroark/Zorua.) `;
  569. }
  570. if (this.battle.gen === 3) {
  571. text += `(Pressure is not visible in Gen 3, so in certain situations, more PP may have been lost than shown here.) `;
  572. }
  573. if (this.pokemonHasClones(clientPokemon)) {
  574. text += `(Your opponent has two indistinguishable Pokémon, making it impossible for you to tell which one has which moves/ability/item.) `;
  575. }
  576. text += `</p>`;
  577. }
  578. if (ZA_MEGAS[toID(pokemon.speciesForme)]) {
  579. text += '<p>Sprite by KingOfThe-X-Roads</p>';
  580. }
  581. return text;
  582. }
  583. Dex.getPokemonIcon = function (pokemon, facingLeft) {
  584. if (pokemon === 'pokeball') {
  585. return `background:transparent url(${Dex.resourcePrefix}sprites/pokemonicons-pokeball-sheet.png) no-repeat scroll -0px 4px`;
  586. } else if (pokemon === 'pokeball-statused') {
  587. return `background:transparent url(${Dex.resourcePrefix}sprites/pokemonicons-pokeball-sheet.png) no-repeat scroll -40px 4px`;
  588. } else if (pokemon === 'pokeball-fainted') {
  589. return `background:transparent url(${Dex.resourcePrefix}sprites/pokemonicons-pokeball-sheet.png) no-repeat scroll -80px 4px;opacity:.4;filter:contrast(0)`;
  590. } else if (pokemon === 'pokeball-none') {
  591. return `background:transparent url(${Dex.resourcePrefix}sprites/pokemonicons-pokeball-sheet.png) no-repeat scroll -80px 4px`;
  592. }
  593.  
  594. let id = toID(pokemon);
  595. if (!pokemon || typeof pokemon === 'string') pokemon = null;
  596. // @ts-expect-error safe, but too lazy to cast
  597. if (pokemon?.speciesForme) id = toID(pokemon.speciesForme);
  598. // @ts-expect-error safe, but too lazy to cast
  599. if (pokemon?.species) id = toID(pokemon.species);
  600. // @ts-expect-error safe, but too lazy to cast
  601. if (pokemon?.volatiles?.formechange && !pokemon.volatiles.transform) {
  602. // @ts-expect-error safe, but too lazy to cast
  603. id = toID(pokemon.volatiles.formechange[1]);
  604. }
  605. let num = this.getPokemonIconNum(id, pokemon?.gender === 'F', facingLeft);
  606.  
  607. let top = Math.floor(num / 12) * 30;
  608. let left = (num % 12) * 40;
  609. let fainted = ((pokemon)?.fainted ?
  610. `;opacity:.3;filter:grayscale(100%) brightness(.5)` : ``);
  611. const url = ZA_DLC_MEGAS[id]?.["fn"]
  612. ? ZA_DLC_MEGAS[id]["fn"] + ") 0px 0px / 36px 36px no-repeat scroll"
  613. : `${Dex.resourcePrefix}sprites/pokemonicons-sheet.png?v20) no-repeat scroll -${left}px -${top}px`
  614. return `background:transparent url(${url}${fainted}`;
  615. }
  616. })();
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment