aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/sender
diff options
context:
space:
mode:
authorCaleb <caleb.mabry.15@cnu.edu>2022-09-08 12:13:14 -0400
committerCaleb <caleb.mabry.15@cnu.edu>2022-09-08 12:13:14 -0400
commit9b8f8c3f5310b6af15edf8ff933e2d63e05707a7 (patch)
treeab70772728eae88c12f0f519304bfb26608c0932 /webAO/client/sender
parent4de6b4fd4e7bc3871d76fded0f32561c814ca003 (diff)
Add Sender support
Diffstat (limited to 'webAO/client/sender')
-rw-r--r--webAO/client/sender/index.ts39
-rw-r--r--webAO/client/sender/sendIC.ts106
-rw-r--r--webAO/client/sender/sendSelf.ts13
-rw-r--r--webAO/client/sender/sendServer.ts10
4 files changed, 168 insertions, 0 deletions
diff --git a/webAO/client/sender/index.ts b/webAO/client/sender/index.ts
new file mode 100644
index 0000000..ce5b488
--- /dev/null
+++ b/webAO/client/sender/index.ts
@@ -0,0 +1,39 @@
+import { sendIC } from "./sendIC";
+import { sendSelf } from './sendSelf'
+import { sendServer } from './sendServer'
+export interface ISender {
+ 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) => void
+ sendSelf: (message: string) => void
+ sendServer: (message: string) => void
+}
+export const sender = {
+ sendIC,
+ sendSelf,
+ sendServer
+
+} \ No newline at end of file
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
diff --git a/webAO/client/sender/sendSelf.ts b/webAO/client/sender/sendSelf.ts
new file mode 100644
index 0000000..66c35fa
--- /dev/null
+++ b/webAO/client/sender/sendSelf.ts
@@ -0,0 +1,13 @@
+import { client } from "../../client";
+
+
+/**
+ * Hook for sending messages to the client
+ * @param {string} message the message to send
+ */
+export const sendSelf = (message: string) => {
+ (<HTMLInputElement>(
+ document.getElementById("client_ooclog")
+ )).value += `${message}\r\n`;
+ client.handleSelf(message);
+} \ No newline at end of file
diff --git a/webAO/client/sender/sendServer.ts b/webAO/client/sender/sendServer.ts
new file mode 100644
index 0000000..a9da3bd
--- /dev/null
+++ b/webAO/client/sender/sendServer.ts
@@ -0,0 +1,10 @@
+import { client } from "../../client";
+import queryParser from "../../utils/queryParser";
+let { mode } = queryParser()
+/**
+ * Hook for sending messages to the server
+ * @param {string} message the message to send
+ */
+export const sendServer = (message: string) => {
+ mode === "replay" ? client.sender.sendSelf(message) : client.serv.send(message);
+} \ No newline at end of file