[nexuiz-commits] r8292 - in trunk/data/qcsrc/server: . bot
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Nov 17 15:29:28 EST 2009
Author: fruitiex
Date: 2009-11-17 15:29:27 -0500 (Tue, 17 Nov 2009)
New Revision: 8292
Modified:
trunk/data/qcsrc/server/bot/bot.qc
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/miscfunctions.qc
Log:
patch by Spaceman: bots send accuracy data but never receive it, add an escape "v" for accuracy
Modified: trunk/data/qcsrc/server/bot/bot.qc
===================================================================
--- trunk/data/qcsrc/server/bot/bot.qc 2009-11-16 21:47:45 UTC (rev 8291)
+++ trunk/data/qcsrc/server/bot/bot.qc 2009-11-17 20:29:27 UTC (rev 8292)
@@ -207,6 +207,9 @@
self.playerskin = self.playerskin_freeme = strzone(bot_skin);
self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
+
+ self.cvar_cl_accuracy_data_share = 1; // share the bots weapon accuracy data with the world
+ self.cvar_cl_accuracy_data_receive = 0; // don't receive any weapon accuracy data
};
void bot_custom_weapon_priority_setup()
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2009-11-16 21:47:45 UTC (rev 8291)
+++ trunk/data/qcsrc/server/g_world.qc 2009-11-17 20:29:27 UTC (rev 8292)
@@ -1342,7 +1342,7 @@
if(cvar("sv_accuracy_data_send")) {
string stats_to_send;
- FOR_EACH_PLAYER(other) { // make the string to send
+ FOR_EACH_CLIENT(other) { // make the string to send
FixIntermissionClient(other);
if(other.cvar_cl_accuracy_data_share) {
@@ -1360,10 +1360,10 @@
}
}
- FOR_EACH_PLAYER(other) { // send the stats string to all the willing clients
+ FOR_EACH_REALCLIENT(other) { // only spam humans
Score_NicePrint(other); // print the score
- if(other.cvar_cl_accuracy_data_receive)
+ if(other.cvar_cl_accuracy_data_receive) // send the stats string to all the willing clients
bprint(stats_to_send);
}
} else { // ye olde message
Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc 2009-11-16 21:47:45 UTC (rev 8291)
+++ trunk/data/qcsrc/server/miscfunctions.qc 2009-11-17 20:29:27 UTC (rev 8292)
@@ -420,85 +420,104 @@
string formatmessage(string msg)
{
- float p, p1, p2;
- float n;
- string escape;
- string replacement;
- p = 0;
- n = 7;
- while (1)
- {
- if (n < 1)
- break; // too many replacements
- n = n - 1;
- p1 = strstr(msg, "%", p); // NOTE: this destroys msg as it's a tempstring!
- p2 = strstr(msg, "\\", p); // NOTE: this destroys msg as it's a tempstring!
+ float p, p1, p2;
+ float n;
+ string escape;
+ string replacement;
+ p = 0;
+ n = 7;
- if (p1 < 0)
- p1 = p2;
- if (p2 < 0)
- p2 = p1;
- p = min(p1, p2);
+ while (1) {
+ if (n < 1)
+ break; // too many replacements
- if (p < 0)
- break;
- replacement = substring(msg, p, 2);
- escape = substring(msg, p + 1, 1);
- if (escape == "%")
- replacement = "%";
- else if (escape == "\\")
- replacement = "\\";
- else if (escape == "n")
- replacement = "\n";
- else if (escape == "a")
- replacement = ftos(floor(self.armorvalue));
- else if (escape == "h")
- replacement = ftos(floor(self.health));
- else if (escape == "l")
- replacement = NearestLocation(self.origin);
- else if (escape == "y")
- replacement = NearestLocation(self.cursor_trace_endpos);
- else if (escape == "d")
- replacement = NearestLocation(self.death_origin);
- else if (escape == "w")
- {
- float wep;
- wep = self.weapon;
- if (!wep)
- wep = self.switchweapon;
- if (!wep)
- wep = self.cnt;
- replacement = W_Name(wep);
- }
- else if (escape == "W")
- {
- if (self.items & IT_SHELLS) replacement = "shells";
- else if (self.items & IT_NAILS) replacement = "bullets";
- else if (self.items & IT_ROCKETS) replacement = "rockets";
- else if (self.items & IT_CELLS) replacement = "cells";
- else replacement = "batteries"; // ;)
- }
- else if (escape == "x")
- {
- replacement = self.cursor_trace_ent.netname;
- if (!replacement || !self.cursor_trace_ent)
- replacement = "nothing";
- }
- else if (escape == "p")
- {
- if (self.last_selected_player)
- replacement = self.last_selected_player.netname;
- else
- replacement = "(nobody)";
- }
- else if (escape == "s")
- replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1'));
- else if (escape == "S")
- replacement = ftos(vlen(self.velocity));
- msg = strcat(substring(msg, 0, p), replacement, substring(msg, p+2, strlen(msg) - (p+2)));
- p = p + strlen(replacement);
+ n = n - 1;
+ p1 = strstr(msg, "%", p); // NOTE: this destroys msg as it's a tempstring!
+ p2 = strstr(msg, "\\", p); // NOTE: this destroys msg as it's a tempstring!
+
+ if (p1 < 0)
+ p1 = p2;
+
+ if (p2 < 0)
+ p2 = p1;
+
+ p = min(p1, p2);
+
+ if (p < 0)
+ break;
+
+ replacement = substring(msg, p, 2);
+ escape = substring(msg, p + 1, 1);
+
+ if (escape == "%")
+ replacement = "%";
+ else if (escape == "\\")
+ replacement = "\\";
+ else if (escape == "n")
+ replacement = "\n";
+ else if (escape == "a")
+ replacement = ftos(floor(self.armorvalue));
+ else if (escape == "h")
+ replacement = ftos(floor(self.health));
+ else if (escape == "l")
+ replacement = NearestLocation(self.origin);
+ else if (escape == "y")
+ replacement = NearestLocation(self.cursor_trace_endpos);
+ else if (escape == "d")
+ replacement = NearestLocation(self.death_origin);
+ else if (escape == "w") {
+ float wep;
+ wep = self.weapon;
+ if (!wep)
+ wep = self.switchweapon;
+ if (!wep)
+ wep = self.cnt;
+ replacement = W_Name(wep);
+ } else if (escape == "W") {
+ if (self.items & IT_SHELLS) replacement = "shells";
+ else if (self.items & IT_NAILS) replacement = "bullets";
+ else if (self.items & IT_ROCKETS) replacement = "rockets";
+ else if (self.items & IT_CELLS) replacement = "cells";
+ else replacement = "batteries"; // ;)
+ } else if (escape == "x") {
+ replacement = self.cursor_trace_ent.netname;
+ if (!replacement || !self.cursor_trace_ent)
+ replacement = "nothing";
+ } else if (escape == "p") {
+ if (self.last_selected_player)
+ replacement = self.last_selected_player.netname;
+ else
+ replacement = "(nobody)";
+ } else if (escape == "s")
+ replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1'));
+ else if (escape == "S")
+ replacement = ftos(vlen(self.velocity));
+ else if (escape == "v") {
+ float weapon_number;
+ local entity stats;
+
+ if(self.classname == "spectator")
+ stats = self.enemy;
+ else
+ stats = self;
+
+ weapon_number = stats.weapon;
+
+ if (!weapon_number)
+ weapon_number = stats.switchweapon;
+
+ if (!weapon_number)
+ weapon_number = stats.cnt;
+
+ if(stats.cvar_cl_accuracy_data_share && stats.stats_fired[weapon_number - 1])
+ replacement = ftos(bound(0, floor(100 * stats.stats_hit[weapon_number - 1] / stats.stats_fired[weapon_number - 1]), 100));
+ else
+ replacement = "~"; // or something to indicate NULL, not available
+ }
+
+ msg = strcat(substring(msg, 0, p), replacement, substring(msg, p+2, strlen(msg) - (p+2)));
+ p = p + strlen(replacement);
}
-
return msg;
}
More information about the nexuiz-commits
mailing list