Team chat uber spam
This commit is contained in:
parent
9bdc12094e
commit
59508b182b
@ -11,15 +11,23 @@
|
||||
|
||||
namespace chat_stack {
|
||||
|
||||
|
||||
void Say(const std::string& message, bool team) {
|
||||
stack.push({ message, team });
|
||||
}
|
||||
|
||||
void OnCreateMove() {
|
||||
if (last_say > g_GlobalVars->curtime) last_say = 0;
|
||||
if (g_GlobalVars->curtime - last_say <= CHATSTACK_INTERVAL) return;
|
||||
std::string message;
|
||||
if (!stack.empty()) {
|
||||
message = stack.top();
|
||||
const msg_t& msg = stack.top();
|
||||
stack.pop();
|
||||
if (message.size()) {
|
||||
g_IEngine->ServerCmd(format("say \"", message, '"').c_str());
|
||||
if (msg.text.size()) {
|
||||
//logging::Info("Saying %s %i", msg.text.c_str(), msg.text.size());
|
||||
if (msg.team)
|
||||
g_IEngine->ServerCmd(format("say_team \"", msg.text.c_str(), '"').c_str());
|
||||
else
|
||||
g_IEngine->ServerCmd(format("say \"", msg.text.c_str(), '"').c_str());
|
||||
last_say = g_GlobalVars->curtime;
|
||||
}
|
||||
}
|
||||
@ -30,7 +38,7 @@ void Reset() {
|
||||
last_say = 0.0f;
|
||||
}
|
||||
|
||||
std::stack<std::string> stack;
|
||||
std::stack<msg_t> stack;
|
||||
float last_say = 0.0f;
|
||||
|
||||
}
|
||||
|
@ -18,10 +18,16 @@
|
||||
|
||||
namespace chat_stack {
|
||||
|
||||
struct msg_t {
|
||||
std::string text;
|
||||
bool team;
|
||||
};
|
||||
|
||||
void Say(const std::string& message, bool team = false);
|
||||
void OnCreateMove();
|
||||
void Reset();
|
||||
|
||||
extern std::stack<std::string> stack;
|
||||
extern std::stack<msg_t> stack;
|
||||
extern float last_say;
|
||||
|
||||
};
|
||||
|
@ -536,6 +536,7 @@ static const std::string list_tf2 = R"(
|
||||
"uberspam_ready"
|
||||
"uberspam_used"
|
||||
"uberspam_ended"
|
||||
"uberspam_team"
|
||||
]
|
||||
|
||||
"Follow Bot" [
|
||||
|
@ -130,6 +130,6 @@ void KillSayEventListener::FireGameEvent(IGameEvent* event) {
|
||||
if (!hacks::shared::killsay::killsay_mode) return;
|
||||
std::string message = hacks::shared::killsay::ComposeKillSay(event);
|
||||
if (message.size()) {
|
||||
chat_stack::stack.push(message);
|
||||
chat_stack::Say(message);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void CreateMove() {
|
||||
if (random_order) current_index = rand() % source->size();
|
||||
std::string spamString = source->at(current_index);
|
||||
ReplaceString(spamString, "\\n", "\n");
|
||||
chat_stack::stack.push(spamString);
|
||||
chat_stack::Say(spamString);
|
||||
current_index++;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ static CatVar on_ready(CV_SWITCH, "uberspam_ready", "1", "Uber Ready");
|
||||
static CatVar on_used(CV_SWITCH, "uberspam_used", "1", "Uber Used");
|
||||
static CatVar on_ended(CV_SWITCH, "uberspam_ended", "1", "Uber Ended");
|
||||
static CatVar on_build(CV_INT, "uberspam_build", "25", "Uber Build", "Send a message every #% ubercharge. 0 = never send", 0, 100);
|
||||
static CatVar team_chat(CV_SWITCH, "uberspam_team", "1", "Uber Team Chat", "Send uberspam messages in team chat");
|
||||
static CatVar custom_file(CV_STRING, "uberspam_file", "uberspam.txt", "Ubercharge Spam File", "Use cat_uberspam_file_reload! Same as spam/killsay files.");
|
||||
static CatCommand custom_file_reload("uberspam_file_reload", "Reload Ubercharge Spam File", []() {
|
||||
custom_lines.Load(std::string(custom_file.GetString()));
|
||||
@ -56,20 +57,22 @@ void CreateMove() {
|
||||
bool release = CE_BYTE(LOCAL_W, netvar.bChargeRelease);
|
||||
if (release_last_frame != release) {
|
||||
if (release) {
|
||||
if (on_used) chat_stack::stack.push(GetSource()->at(1));
|
||||
if (on_used) chat_stack::Say(GetSource()->at(1), !!team_chat);
|
||||
} else {
|
||||
if (on_ended) chat_stack::stack.push(GetSource()->at(2));
|
||||
if (on_ended) chat_stack::Say(GetSource()->at(2), !!team_chat);
|
||||
}
|
||||
}
|
||||
if (!release && ((int)(100.0f * charge) != last_charge)) {
|
||||
if (charge == 1.0f) {
|
||||
if (on_ready) chat_stack::stack.push(GetSource()->at(0));
|
||||
if (on_ready) chat_stack::Say(GetSource()->at(0), !!team_chat);
|
||||
} else {
|
||||
if ((int)(charge * 100.0f) != 0 && on_build) {
|
||||
if (((int)(charge * 100.0f) % (int)on_build) == 0) {
|
||||
int chargeperline = ((int)on_build >= 100) ? (100 / (GetSource()->size() - 2)) : (int)on_build;
|
||||
if (chargeperline < 1) chargeperline = 1;
|
||||
if ((int)(charge * 100.0f) % chargeperline == 0) {
|
||||
std::string res = GetSource()->at(ChargePercentLineIndex(charge));
|
||||
ReplaceString(res, "%i%", std::to_string((int)(charge * 100.0f)));
|
||||
chat_stack::stack.push(res);
|
||||
chat_stack::Say(res, !!team_chat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user