diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-10-12 18:25:14 +0200 |
|---|---|---|
| committer | stonedDiscord <Tukz@gmx.de> | 2022-10-12 18:25:14 +0200 |
| commit | 8a7942c0565298c29edbf0b271d5d7c7f9e56fd8 (patch) | |
| tree | 67b788f40b7a4713904836de05f0e5876c32bd79 /webAO/client/sender/sendIC.ts | |
| parent | a83c8962b68f2cc0a0e22d988b8ff030057454e5 (diff) | |
| parent | 82983e0c38383ec2602b4f41327342d1c8d0a8fd (diff) | |
Merge branch 'master' into 2fa
Diffstat (limited to 'webAO/client/sender/sendIC.ts')
| -rw-r--r-- | webAO/client/sender/sendIC.ts | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/webAO/client/sender/sendIC.ts b/webAO/client/sender/sendIC.ts new file mode 100644 index 0000000..9064115 --- /dev/null +++ b/webAO/client/sender/sendIC.ts @@ -0,0 +1,106 @@ +import { extrafeatures } from "../../client"; +import { escapeChat } from "../../encoding"; +import {client} from '../../client' +import queryParser from "../../utils/queryParser"; +let {mode} = queryParser() + +/** + * Sends an in-character chat message. + * @param {number} deskmod controls the desk + * @param {string} speaking who is speaking + * @param {string} name the name of the current character + * @param {string} silent whether or not it's silent + * @param {string} message the message to be sent + * @param {string} side the name of the side in the background + * @param {string} sfx_name the name of the sound effect + * @param {number} emote_modifier whether or not to zoom + * @param {number} sfx_delay the delay (in milliseconds) to play the sound effect + * @param {number} objection_modifier the number of the shout to play + * @param {string} evidence the filename of evidence to show + * @param {boolean} flip change to 1 to reverse sprite for position changes + * @param {boolean} realization screen flash effect + * @param {number} text_color text color + * @param {string} showname custom name to be displayed (optional) + * @param {number} other_charid paired character (optional) + * @param {number} self_offset offset to paired character (optional) + * @param {number} noninterrupting_preanim play the full preanim (optional) + */ +export const sendIC = ( + deskmod: number, + preanim: string, + name: string, + emote: string, + message: string, + side: string, + sfx_name: string, + emote_modifier: number, + sfx_delay: number, + objection_modifier: number, + evidence: number, + flip: boolean, + realization: boolean, + text_color: number, + showname: string, + other_charid: string, + self_hoffset: number, + self_yoffset: number, + noninterrupting_preanim: boolean, + looping_sfx: boolean, + screenshake: boolean, + frame_screenshake: string, + frame_realization: string, + frame_sfx: string, + additive: boolean, + effect: string +) => { + let extra_cccc = ""; + let other_emote = ""; + let other_offset = ""; + let extra_27 = ""; + let extra_28 = ""; + + if (extrafeatures.includes("cccc_ic_support")) { + const self_offset = extrafeatures.includes("y_offset") + ? `${self_hoffset}<and>${self_yoffset}` + : self_hoffset; // HACK: this should be an & but client fucked it up and all the servers adopted it + if (mode === "replay") { + other_emote = "##"; + other_offset = "#0#0"; + } + extra_cccc = `${escapeChat( + showname + )}#${other_charid}${other_emote}#${self_offset}${other_offset}#${Number( + noninterrupting_preanim + )}#`; + + if (extrafeatures.includes("looping_sfx")) { + extra_27 = `${Number(looping_sfx)}#${Number( + screenshake + )}#${frame_screenshake}#${frame_realization}#${frame_sfx}#`; + if (extrafeatures.includes("effects")) { + extra_28 = `${Number(additive)}#${escapeChat(effect)}#`; + } + } + } + + const serverMessage = + `MS#${deskmod}#${escapeChat(preanim)}#${escapeChat(name)}#${escapeChat( + emote + )}` + + `#${escapeChat(message)}#${escapeChat(side)}#${escapeChat( + sfx_name + )}#${emote_modifier}` + + `#${client.charID}#${sfx_delay}#${Number(objection_modifier)}#${Number( + evidence + )}#${Number(flip)}#${Number( + realization + )}#${text_color}#${extra_cccc}${extra_27}${extra_28}%`; + + client.sender.sendServer(serverMessage); + if (mode === "replay") { + (<HTMLInputElement>( + document.getElementById("client_ooclog") + )).value += `wait#${(<HTMLInputElement>document.getElementById("client_replaytimer")).value + }#%\r\n`; + } +}
\ No newline at end of file |
