Skip to content
118 changes: 118 additions & 0 deletions eventfunctions/toys/vibe_reverb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
const { messageSendChannel } = require("../../functions/messagefunctions");
const { setUserVar, getUserVar } = require("../../functions/usercontext");

const initial_timespan = 180000
const timespan_inc = 15000
const decay_period = 30000

const newline = new RegExp(/[^\r\n]+/g)
const OOC = new RegExp(/^[*][^*].*[^*][*]$/)
const LOUD = new RegExp(/(\b[A-Z]['A-Z]+|\b[A-Z]\b)/)
const BOLD = new RegExp(/([\*][\*])/)

function msgfunction(userid, data) {

// Catch Message, and Check for OOC, Whispers, or Shouting
intensity = volumetest(data.msgcontent)
//console.log(intensity);

// Escape if purely OOC message
if (intensity == 0) return;

//Update End Time and Increment Vibe Intensity
if(getUserVar(userid, "reverbEndTime") == undefined) {
// Set initial 3 minute timer
setUserVar(userid, "reverbEndTime", Date.now() + initial_timespan);
} else {
// Increment reverbEndTime by 15s x intensity per Message
setUserVar(userid, "reverbEndTime", getUserVar(userid, "reverbEndTime") + (timespan_inc * intensity));
}

// Declare Initial reverbDecayTime
if(getUserVar(userid, "reverbDecayTime") == undefined) {
setUserVar(userid, "reverbDecayTime", Date.now() + (decay_period * intensity));
}
else
{
// Override Next Decay time with a new value based on the intensity if it is longer than the current delay
setUserVar(userid, "reverbDecayTime", Math.max(Date.now() + (decay_period * intensity), getUserVar(userid, "reverbDecayTime")));
}

// Increment reverbVibeIntensity based on intensity of message text
setUserVar(userid, "reverbVibeIntensity", Math.min(getUserVar(userid, "reverbVibeIntensity") + (1 * intensity), 20));
return;
}

async function functiontick(userID) {
// Decay Intensity every Decay Period until 0
if (getUserVar(userID, "reverbDecayTime") < Date.now() && getUserVar(userID, "reverbDecayTime") != undefined)
{
setUserVar(userID, "reverbVibeIntensity", Math.max(getUserVar(userID, "reverbVibeIntensity") - 1, 0));
setUserVar(userID, "reverbDecayTime", Date.now() + decay_period);
}

// Clear Values When Vibe Stops
if (getUserVar(userID, "reverbEndTime") < Date.now() && getUserVar(userID, "reverbVibeIntensity") == 0) {
console.log(`${userID}'s Reverb Vibe has stopped`)
setUserVar(userID, "reverbEndTime", undefined)
setUserVar(userID, "reverbDecayTime", undefined)
}
}

function volumetest(message) {
// Split into lines
arrayOfLines = message.match(newline);
//console.log(`ARRAY OF LINES: ${arrayOfLines}\n`);

intensityMod = 0;
// Discard OOC Lines
arrayOfLines.forEach((line) => {

// Check for Whispers
let Whisper = false;
if(line.startsWith("-#"))
{
Whisper = true;
line = line.replace("-# ", "");
}

// Ignore OOC Lines
if(OOC.test(line))
{
//console.log(`OOC: ${line} : ${Whisper}`);
}
else if(!Whisper && LOUD.test(line) && (line.match(BOLD) || []).length >= 2)
{
//console.log(`BRIAN: ${line} : ${Whisper}`);
return intensityMod = 4;
}
else if(!Whisper && LOUD.test(line)){
if(intensityMod < 3) intensityMod = 3;
//console.log(`LOUD: ${line} : ${Whisper}`);
}
else if(!Whisper && (line.match(BOLD) || []).length >= 2)
{
if(intensityMod < 2) intensityMod = 2;
//console.log(`BOLD : ${line} : ${Whisper}`);
}
else if(Whisper && (line.match(BOLD) || []).length >= 2)
{
if(intensityMod < 0.75) intensityMod = 0.75;
//console.log(`BOLD Whisper: ${line} : ${Whisper}`);
}
else if(Whisper)
{
if(intensityMod < 0.5) intensityMod = 0.5;
//console.log(`Whisper: ${line} : ${Whisper}`);
}
else
{
if(intensityMod < 1) intensityMod = 1;
//console.log(`Normal: ${line} : ${Whisper}`);
}
});
return intensityMod;
}

exports.functiontick = functiontick;
exports.msgfunction = msgfunction;
27 changes: 27 additions & 0 deletions toys/Vibrator/vibe_reverb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { getUserVar, setUserVar } = require("../../functions/usercontext")

// This vibrator will only function if getUserVar(userID, "reverbEndTime") has any value
exports.vibescale = (data) => {
//console.log(`${data.userID}`)
//console.log(`${getUserVar(data.userID, "reverbVibeIntensity")/10}`);
return (isNaN(Math.max(0, Math.min(getUserVar(data.userID, "reverbVibeIntensity")/10, 2))) ? 0 : Math.max(0, Math.min(getUserVar(data.userID, "reverbVibeIntensity")/10, 2)));
} // Ranging between 0 and 2

exports.calcVibeEffect = function(data) {
//console.log(`${data.userID}`)
return (getUserVar(data.userID, "reverbEndTime") ? data.intensity * this.vibescale(data) : 0)
}

exports.onUnequip = (data) => {
setUserVar(data.userID, "reverbEndTime", undefined);
setUserVar(data.userID, "reverbDecayTime", undefined);
setUserVar(data.userID, "reverbVibeIntensity", 0);
}

exports.onEquip = (data) => {
setUserVar(data.userID, "reverbEndTime", undefined);
setUserVar(data.userID, "reverbDecayTime", undefined);
setUserVar(data.userID, "reverbVibeIntensity", 0);
}

exports.toyname = "Reverb Vibe"
2 changes: 1 addition & 1 deletion toys/defaulttoy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Toy() {
// Calculation for effective arousal change
// Note, this should be used for checks more focused around the vibe - it will be
// further multiplied by the chastity's checks for this, if applicable.
this.calcVibeEffect = function (data) { return 0 }
this.calcVibeEffect = (data) => { return 0 }

// Name for the toy
this.toyname = "Default Toy"
Expand Down