|
| 1 | +import settings from "../../settings" |
| 2 | +import Skyblock from "../../utils/Skyblock" |
| 3 | + |
| 4 | +const colours = ["§8", "§c", "§6", "§e", "§2", "§a", "§b"] |
| 5 | +const thresholds = [5, 10, 15, 20, 25, 30, 35] |
| 6 | + |
| 7 | +// BUFF! You were splashed by BingoSplasher with Mushed Glowy Tonic I! Press TAB or type /effects to view your active effects! |
| 8 | +const regex = |
| 9 | + /^BUFF! (?:You splashed yourself|You were splashed by (\w{1,16})) with (.*)! Press TAB or type \/effects to view your active effects!$/ |
| 10 | + |
| 11 | +let splashedPotions = {} |
| 12 | +let messageID = 5967 |
| 13 | + |
| 14 | +// splash combo! |
| 15 | +register("chat", (user = Player.getName(), potion, event) => { |
| 16 | + if (!Skyblock.inSkyblock) return |
| 17 | + if (!settings().splashCombo) return |
| 18 | + |
| 19 | + // create user |
| 20 | + if (!splashedPotions[user]) { |
| 21 | + messageID += 1 |
| 22 | + splashedPotions[user] = { |
| 23 | + displayName: |
| 24 | + World.getAllPlayers() |
| 25 | + ?.find((player) => player?.getName() === user) |
| 26 | + ?.getDisplayName()?.text || user, |
| 27 | + id: messageID, |
| 28 | + combo: 0, |
| 29 | + potions: [] |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + let currentUser = splashedPotions[user] |
| 34 | + |
| 35 | + // return if the same potion type is already splashed |
| 36 | + // TODO: disregard potion level (roman numerals) |
| 37 | + if (currentUser.potions.includes(potion)) return |
| 38 | + |
| 39 | + currentUser.potions.push(potion) |
| 40 | + currentUser.combo += 1 |
| 41 | + |
| 42 | + let combo = currentUser.combo |
| 43 | + |
| 44 | + // chat message |
| 45 | + /* |
| 46 | + ChatLib.clearChat(currentUser.id) |
| 47 | + new Message(`Combo: ${currentUser.combo}`) |
| 48 | + .setChatLineId(currentUser.id) |
| 49 | + .chat() |
| 50 | + */ |
| 51 | + |
| 52 | + // title |
| 53 | + let colour = colours[thresholds.findIndex((threshold) => combo < threshold)] |
| 54 | + if (colour === undefined) colour = "&b" |
| 55 | + Client.showTitle( |
| 56 | + `${colour}${combo} combo!`, |
| 57 | + "", // TODO: fix the splasher not showing |
| 58 | + // `&7Splasher: ${currentUser.displayName}` |
| 59 | + 0, |
| 60 | + 60, |
| 61 | + 20 |
| 62 | + ) |
| 63 | + |
| 64 | + // sounds |
| 65 | + const pitch = 0.5 + combo / 20 |
| 66 | + World.playSound("note.pling", 100, pitch) |
| 67 | + if (combo <= 10) return |
| 68 | + new Thread(() => { |
| 69 | + Thread.sleep(30) |
| 70 | + World.playSound("random.successful_hit", 100, pitch - 0.5) |
| 71 | + if (combo <= 15) return |
| 72 | + Thread.sleep(5) |
| 73 | + World.playSound("random.orb", 100, pitch - 1) |
| 74 | + }).start() |
| 75 | +}).setCriteria(regex) |
| 76 | + |
| 77 | +register("worldLoad", init) |
| 78 | + |
| 79 | +function init() { |
| 80 | + splashedPotions = {} |
| 81 | + messageID = 5967 |
| 82 | +} |
0 commit comments