[nexuiz-commits] r8523 - in trunk/data: . qcsrc/client qcsrc/common qcsrc/menu/nexuiz qcsrc/server qcsrc/server/bot

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jan 22 14:46:23 EST 2010


Author: div0
Date: 2010-01-22 14:46:23 -0500 (Fri, 22 Jan 2010)
New Revision: 8523

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/common/items.qc
   trunk/data/qcsrc/common/items.qh
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c
   trunk/data/qcsrc/menu/nexuiz/weaponslist.c
   trunk/data/qcsrc/server/bot/bot.qc
   trunk/data/qcsrc/server/cl_weapons.qc
Log:
make weapons named, not numbered, everywhere

Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/defaultNexuiz.cfg	2010-01-22 19:46:23 UTC (rev 8523)
@@ -406,9 +406,9 @@
 set bot_ai_aimskill_offset 0.3 "Amount of error induced to the bots aim"
 set bot_ai_aimskill_think 1 "Aiming velocity. Use values below 1 for slower aiming"
 set bot_ai_custom_weapon_priority_distances "300 850"	"Define close and far distances in any order. Based on the distance to the enemy bots will choose different weapons"
-set bot_ai_custom_weapon_priority_far "11 7 15 14 9 4 5 8 13 6 1 3 16 2"	"Desired weapons for far distances ordered by priority"
-set bot_ai_custom_weapon_priority_mid "11 9 7 16 4 5 3 15 14 6 13 8 2 1"	"Desired weapons for middle distances ordered by priority"
-set bot_ai_custom_weapon_priority_close "11 7 3 13 14 8 6 4 2 5 15 1 16"	"Desired weapons for close distances ordered by priority"
+set bot_ai_custom_weapon_priority_far   "minstanex nex campingrifle rocketlauncher grenadelauncher electro hagar hlac crylink laser uzi fireball shotgun tuba"	"Desired weapons for far distances ordered by priority"
+set bot_ai_custom_weapon_priority_mid   "minstanex rocketlauncher nex fireball grenadelauncher electro uzi campingrifle crylink hlac hagar shotgun laser tuba"	"Desired weapons for middle distances ordered by priority"
+set bot_ai_custom_weapon_priority_close "minstanex nex uzi hlac tuba hagar crylink grenadelauncher shotgun electro campingrifle rocketlauncher laser fireball"	"Desired weapons for close distances ordered by priority"
 set bot_ai_weapon_combo 1	"Enable bots to do weapon combos"
 set bot_ai_weapon_combo_threshold 0.3	"Try to make a combo N seconds after the last attack"
 set bot_ai_friends_aware_pickup_radius "500"	"Bots will not pickup items if a team mate is this distance near the item"
@@ -1452,14 +1452,14 @@
 alias allready "sv_cmd allready"
 
 // note: these cvars use weapon NUMBERS. Use the menu to edit this cvar, or look the numbers up in qcsrc/common/constants.qh.
-seta cl_weaponpriority "11 9 7 4 13 8 6 15 3 5 14 2 1 12 10" "weapon priority list (edit it using the menu, numbers see constants.qh)"
+seta cl_weaponpriority "minstanex rocketlauncher nex grenadelauncher fireball hlac hagar crylink campingrifle uzi electro tuba shotgun laser hook porto" "weapon priority list"
 seta cl_weaponpriority_useforcycling 0 "when set, weapon cycling by the mouse wheel makes use of the weapon priority list"
-seta cl_weaponpriority0 "9 4 13 8 14" "use impulse 200 for prev gun from this list, 210 for best gun, 220 for next gun.  Default value: explosives"
-seta cl_weaponpriority1 "11 7 6 5 1"  "use impulse 201 for prev gun from this list, 211 for best gun, 221 for next gun.  Default value: energy"
-seta cl_weaponpriority2 "11 7 15 3"   "use impulse 202 for prev gun from this list, 212 for best gun, 222 for next gun.  Default value: hitscan exact"
-seta cl_weaponpriority3 "11 7 15 3 2" "use impulse 203 for prev gun from this list, 213 for best gun, 223 for next gun.  Default value: hitscan all"
-seta cl_weaponpriority4 "4 13 8 6 2"  "use impulse 204 for prev gun from this list, 214 for best gun, 224 for next gun.  Default value: spam weapons"
-seta cl_weaponpriority5 "1 12 10"     "use impulse 205 for prev gun from this list, 215 for best gun, 225 for next gun.  Default value: weapons for moving"
+seta cl_weaponpriority0 "rocketlauncher grenadelauncher hagar fireball" "use impulse 200 for prev gun from this list, 210 for best gun, 220 for next gun.  Default value: explosives"
+seta cl_weaponpriority1 "minstanex nex crylink hlac electro laser"      "use impulse 201 for prev gun from this list, 211 for best gun, 221 for next gun.  Default value: energy"
+seta cl_weaponpriority2 "minstanex nex campingrifle"                    "use impulse 202 for prev gun from this list, 212 for best gun, 222 for next gun.  Default value: hitscan exact"
+seta cl_weaponpriority3 "minstanex nex campingrifle uzi shotgun"        "use impulse 203 for prev gun from this list, 213 for best gun, 223 for next gun.  Default value: hitscan all"
+seta cl_weaponpriority4 "grenadelauncher hlac hagar crylink shotgun"    "use impulse 204 for prev gun from this list, 214 for best gun, 224 for next gun.  Default value: spam weapons"
+seta cl_weaponpriority5 "laser hook porto"                              "use impulse 205 for prev gun from this list, 215 for best gun, 225 for next gun.  Default value: weapons for moving"
 seta cl_weaponpriority6 "" "use impulse 206 for prev gun from this list, 216 for best gun, 226 for next gun"
 seta cl_weaponpriority7 "" "use impulse 207 for prev gun from this list, 217 for best gun, 227 for next gun"
 seta cl_weaponpriority8 "" "use impulse 208 for prev gun from this list, 218 for best gun, 228 for next gun"

Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/client/Main.qc	2010-01-22 19:46:23 UTC (rev 8523)
@@ -472,6 +472,7 @@
 
 void GameCommand(string msg)
 {
+	string s;
 	float argc;
 	argc = tokenize_console(msg);
 
@@ -557,6 +558,14 @@
 		}
 		localcmd("sv_cmd debug_shotorg\n");
 	}
+	else if(cmd == "sendcvar") {
+		s = cvar_string(argv(1));
+		if(argv(1) == "cl_weaponpriority")
+			s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
+		else if(substring(argv(1), 0, 17) == "cl_weaponpriority" && strlen(argv(1)) == 18)
+			s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
+		localcmd("cmd sentcvar ", argv(1), " \"", s, "\"\n");
+	}
 	else
 	{
 		print("Invalid command. For a list of supported commands, try cl_cmd help.\n");

Modified: trunk/data/qcsrc/common/items.qc
===================================================================
--- trunk/data/qcsrc/common/items.qc	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/common/items.qc	2010-01-22 19:46:23 UTC (rev 8523)
@@ -89,3 +89,32 @@
 {
 	return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
 }
+string W_NameWeaponOrder_MapFunc(string s)
+{
+	entity wi;
+	if(s == "0" || stof(s))
+	{
+		wi = get_weaponinfo(stof(s));
+		if(wi != dummy_weapon_info)
+			return wi.netname;
+	}
+	return s;
+}
+string W_NameWeaponOrder(string order)
+{
+	return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
+}
+string W_NumberWeaponOrder_MapFunc(string s)
+{
+	float i;
+	if(s == "0" || stof(s))
+		return s;
+	for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+		if(s == get_weaponinfo(i).netname)
+			return ftos(i);
+	return s;
+}
+string W_NumberWeaponOrder(string order)
+{
+	return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
+}

Modified: trunk/data/qcsrc/common/items.qh
===================================================================
--- trunk/data/qcsrc/common/items.qh	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/common/items.qh	2010-01-22 19:46:23 UTC (rev 8523)
@@ -52,6 +52,8 @@
 // functions:
 entity get_weaponinfo(float id);
 string W_FixWeaponOrder(string order, float complete);
+string W_NameWeaponOrder(string order);
+string W_NumberWeaponOrder(string order);
 
 #define WEPSPAWNFLAG_NORMAL 1
 #define WEPSPAWNFLAG_CANCLIMB 2

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/common/util.qc	2010-01-22 19:46:23 UTC (rev 8523)
@@ -701,6 +701,7 @@
 	float i, n, w;
 
 	n = tokenize_console(order);
+	neworder = "";
 	for(i = 0; i < n; ++i)
 	{
 		w = stof(argv(i));
@@ -733,6 +734,19 @@
 	return substring(neworder, 0, strlen(neworder) - 1);
 }
 
+string mapPriorityList(string order, string(string) mapfunc)
+{
+	string neworder;
+	float i, n, w;
+
+	n = tokenize_console(order);
+	neworder = "";
+	for(i = 0; i < n; ++i)
+		neworder = strcat(neworder, mapfunc(argv(i)), " ");
+	
+	return substring(neworder, 0, strlen(neworder) - 1);
+}
+
 string swapInPriorityList(string order, float i, float j)
 {
 	string s;

Modified: trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c	2010-01-22 19:46:23 UTC (rev 8523)
@@ -173,6 +173,6 @@
 	me.TR(me);
 
 	me.gotoRC(me, me.rows - 1, 0);
-		me.TD(me, 1, me.columns, makeNexuizCommandButton("Apply immediately", '0 0 0', "color -1 -1;name \"$_cl_name\";sendcvar cl_weaponpriority;sendcvar cl_zoomfactor;sendcvar cl_zoomspeed;sendcvar cl_autoswitch;sendcvar cl_shownames;sendcvar cl_forceplayermodelsfromnexuiz;sendcvar cl_forceplayermodels", COMMANDBUTTON_APPLY));
+		me.TD(me, 1, me.columns, makeNexuizCommandButton("Apply immediately", '0 0 0', "color -1 -1;name \"$_cl_name\";cl_cmd sendcvar cl_weaponpriority;sendcvar cl_zoomfactor;sendcvar cl_zoomspeed;sendcvar cl_autoswitch;sendcvar cl_shownames;sendcvar cl_forceplayermodelsfromnexuiz;sendcvar cl_forceplayermodels", COMMANDBUTTON_APPLY));
 }
 #endif

Modified: trunk/data/qcsrc/menu/nexuiz/weaponslist.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/weaponslist.c	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/menu/nexuiz/weaponslist.c	2010-01-22 19:46:23 UTC (rev 8523)
@@ -33,12 +33,12 @@
 {
 	// read in cvar?
 	string s, t;
-	s = cvar_string("cl_weaponpriority");
+	s = W_NumberWeaponOrder(cvar_string("cl_weaponpriority"));
 	t = W_FixWeaponOrder(s, 1);
 	if(t != s)
 	{
 		print("AUTOFIXED\n");
-		cvar_set("cl_weaponpriority", t);
+		cvar_set("cl_weaponpriority", W_NameWeaponOrder(t));
 	}
 	me.nItems = tokenize_console(t);
 	drawListBox(me);
@@ -81,7 +81,7 @@
 	float n, i;
 	string s;
 	entity e;
-	n = tokenize_console(cvar_string("cl_weaponpriority"));
+	n = tokenize_console(cvar_string(W_NumberWeaponOrder("cl_weaponpriority")));
 	s = "";
 	for(i = 0; i < n; ++i)
 	{

Modified: trunk/data/qcsrc/server/bot/bot.qc
===================================================================
--- trunk/data/qcsrc/server/bot/bot.qc	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/server/bot/bot.qc	2010-01-22 19:46:23 UTC (rev 8523)
@@ -245,7 +245,7 @@
 	bot_weapons_close[0] = -1;
 
 	// Parse far distance weapon priorities
-	tokens = tokenizebyseparator(cvar_string("bot_ai_custom_weapon_priority_far")," ");
+	tokens = tokenizebyseparator(W_NumberWeaponOrder(cvar_string("bot_ai_custom_weapon_priority_far"))," ");
 
 	c = 0;
 	for(i=0; i < tokens && c < WEP_COUNT; ++i){
@@ -259,7 +259,7 @@
 		bot_weapons_far[c] = -1;
 
 	// Parse mid distance weapon priorities
-	tokens = tokenizebyseparator(cvar_string("bot_ai_custom_weapon_priority_mid")," ");
+	tokens = tokenizebyseparator(W_NumberWeaponOrder(cvar_string("bot_ai_custom_weapon_priority_mid"))," ");
 
 	c = 0;
 	for(i=0; i < tokens && c < WEP_COUNT; ++i){
@@ -273,7 +273,7 @@
 		bot_weapons_mid[c] = -1;
 
 	// Parse close distance weapon priorities
-	tokens = tokenizebyseparator(cvar_string("bot_ai_custom_weapon_priority_close")," ");
+	tokens = tokenizebyseparator(W_NumberWeaponOrder(cvar_string("bot_ai_custom_weapon_priority_close"))," ");
 
 	c = 0;
 	for(i=0; i < tokens && i < WEP_COUNT; ++i){

Modified: trunk/data/qcsrc/server/cl_weapons.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weapons.qc	2010-01-22 19:46:17 UTC (rev 8522)
+++ trunk/data/qcsrc/server/cl_weapons.qc	2010-01-22 19:46:23 UTC (rev 8523)
@@ -135,7 +135,7 @@
 string W_FixWeaponOrder_ForceComplete(string order)
 {
 	if(order == "")
-		order = cvar_string("cl_weaponpriority");
+		order = W_NumberWeaponOrder(cvar_string("cl_weaponpriority"));
 	return W_FixWeaponOrder(order, 1);
 }
 



More information about the nexuiz-commits mailing list