Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-11-2012, 03:42 AM
Madrigal
Fire Beetle
 
Join Date: Mar 2010
Posts: 10
Default #practices command

Hey,

For some odd reason or another, I remembered wanting to add practice points to one of my characters a couple months back and couldn't find a GM command that would do that.

Granted, EQEmu has already implemented a wide variety of commands that will set a target's skills to a specific value -- so this command may seem a bit superfluous -- but sometimes the GMs may want to give the player a bit of a bonus in the form of a practice point or two.

This code will do that, allowing a GM to either add practice points to a player or to set their existing total to a desired amount. Because no one in their right mind would ever want more than a few thousand practices, I limited the parameters of value to 5000.

#practices [add/set] [value]

I didn't have any problems compiling it, and (to my surprise) the damn thing actually seems to work. So I thought I'd post the diffs on the slim chance that somebody would find them useful, or maybe even get committed to the SVN repository. The major drawback to this command is that the player will need to zone (or re-login) in order to see the effects of this command when training from a guildmaster.

I've done some rudimentary error-checking (such as using "#practices set 0" and then trying to practice from the guildmaster before zoning) and everything seems okay. The display does a bit of a line-wrap for practices above 999, but it doesn't seem to affect anything (and maybe it would be better to change the 5000 limit down to 500, which is still more practices than any character would acquire in their lifetime).

Here's hoping somebody besides me finds some use for it, heh.

Madrigal


client.cpp patch
Code:
Index: client.cpp
===================================================================
--- client.cpp	(revision 2100)
+++ client.cpp	(working copy)
@@ -5349,6 +5349,13 @@
 	SendCrystalCounts();
 }
 
+void Client::AddPractices(uint32 Practices)
+{
+	m_pp.points += Practices;
+
+	Save();
+}
+
 // Processes a client request to inspect a SoF client's equipment.
 void Client::ProcessInspectRequest(Client* requestee, Client* requester) {
 	if(requestee && requester) {
client.h patch
Code:
Index: client.h
===================================================================
--- client.h	(revision 2100)
+++ client.h	(working copy)
@@ -475,6 +475,9 @@
 	void	SetEbonCrystals(uint32 Crystals) { m_pp.currentEbonCrystals = Crystals; }
 	void	AddCrystals(uint32 Radiant, uint32 Ebon);
 	void	SendCrystalCounts();
+	void	SetPractices(uint32 Practices) { m_pp.points = Practices; }
+	int32	GetPractices() { return m_pp.points; }
+	void	AddPractices(uint32 Practices);
 
 	void	AddEXP(uint32 in_add_exp, int8 conlevel = 0xFF, bool resexp = false);
 	void	SetEXP(uint32 set_exp, uint32 set_aaxp, bool resexp=false);
command.cpp patch
Code:
ndex: command.cpp
===================================================================
--- command.cpp	(revision 2100)
+++ command.cpp	(working copy)
@@ -328,6 +328,7 @@
 		command_add("qglobal","[on/off/view] - Toggles qglobal functionality on an NPC",100,command_qglobal) ||
 		command_add("loc","- Print out your or your target's current location and heading",0,command_loc) ||
 		command_add("goto","[x] [y] [z] - Teleport to the provided coordinates or to your target",10,command_goto) ||
+		command_add("practices","[add/set] [value] - Adds or sets practices to a player. Must zone afterward to take effect.",100,command_practices) ||
 #ifdef BUGTRACK
 		command_add("bugtrack","[bug description] - Report a bug",0,command_bug) ||
 #endif
@@ -4683,6 +4684,44 @@
 		c->MovePC(zone->GetZoneID(), zone->GetInstanceID(), atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]), 0.0f);
 }
 
+void command_practices(Client *c, const Seperator *sep)
+{
+	Client *t=c;
+
+	if(c->GetTarget() && c->GetTarget()->IsClient())
+		t=c->GetTarget()->CastToClient();
+
+	if ((strcasecmp( sep->arg[1], "add" ) == 0 ) && (sep->IsNumber(2)))
+	{
+		if ((atoi(sep->arg[2]) < 1) || (atoi(sep->arg[2]) > 5000))
+			c->Message(0, "Error: #practices add <value> must range from 1 to 5000.");
+		else if (((t->GetPractices()) + (atoi(sep->arg[2]))) > 5000)
+			c->Message(0, "Error: Target has too many practices already.  Keep the total to 5000 or less.");
+		else
+		{
+			t->AddPractices(atoi(sep->arg[2]));
+			t->Save();
+			if (atoi(sep->arg[2]) == 1)
+				t->Message(0, "You have gained 1 practice!");
+			else
+				t->Message(0, "You have gained %i practices!", atoi(sep->arg[2]));
+		}
+	}
+	else if ((strcasecmp( sep->arg[1], "set" ) == 0 ) && (sep->IsNumber(2)))
+	{
+		if ((atoi(sep->arg[2]) < 0) || (atoi(sep->arg[2]) > 5000))
+			c->Message(0, "Error: #practices set <value> must range from 0 to 5000.");
+		else
+		{
+			t->SetPractices(atoi(sep->arg[2]));
+			t->Save();
+			t->Message(0, "Your total practices have been set to %i.", atoi(sep->arg[2]));
+		}
+	}
+	else
+		c->Message(0, "Usage: #practices <add|set> <value>");
+}
+
 #ifdef BUGTRACK
 void command_bug(Client *c, const Seperator *sep)
 {
command.h patch
Code:
Index: command.h
===================================================================
--- command.h	(revision 2100)
+++ command.h	(working copy)
@@ -316,6 +316,7 @@
 void command_picklock(Client *c, const Seperator *sep);
 void command_qtest(Client *c, const Seperator *sep);
 void command_mysql(Client *c, const Seperator *sep);
+void command_practices(Client *c, const Seperator *sep);
 
 #ifdef EMBPERL
 void command_embperl_plugin(Client *c, const Seperator *sep);
Reply With Quote
  #2  
Old 02-11-2012, 05:18 AM
Madrigal
Fire Beetle
 
Join Date: Mar 2010
Posts: 10
Default

Although the above code still works, I tightened up the targeting in command.cpp so that improper targets (NPCs, etc.) will result in an error message rather than target-defaulting to the player who issued the command.

command.cpp patch
Code:
Index: command.cpp
===================================================================
--- command.cpp	(revision 2100)
+++ command.cpp	(working copy)
@@ -328,6 +328,7 @@
 		command_add("qglobal","[on/off/view] - Toggles qglobal functionality on an NPC",100,command_qglobal) ||
 		command_add("loc","- Print out your or your target's current location and heading",0,command_loc) ||
 		command_add("goto","[x] [y] [z] - Teleport to the provided coordinates or to your target",10,command_goto) ||
+		command_add("practices","[add/set] [value] - Adds or sets practices to a player. Must zone afterward to take effect.",100,command_practices) ||
 #ifdef BUGTRACK
 		command_add("bugtrack","[bug description] - Report a bug",0,command_bug) ||
 #endif
@@ -4683,6 +4684,47 @@
 		c->MovePC(zone->GetZoneID(), zone->GetInstanceID(), atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]), 0.0f);
 }
 
+void command_practices(Client *c, const Seperator *sep)
+{
+	Client *t=c;
+
+	if(c->GetTarget() && c->GetTarget()->IsClient())
+	{
+		t=c->GetTarget()->CastToClient();
+		if ((strcasecmp( sep->arg[1], "add" ) == 0 ) && (sep->IsNumber(2)))
+		{
+			if ((atoi(sep->arg[2]) < 1) || (atoi(sep->arg[2]) > 5000))
+				c->Message(0, "Error: #practices: add <value> must range from 1 to 5000.");
+			else if (((t->GetPractices()) + (atoi(sep->arg[2]))) > 5000)
+				c->Message(0, "Error: #practices: Target has too many practices already.");
+			else
+			{
+				t->AddPractices(atoi(sep->arg[2]));
+				t->Save();
+				if (atoi(sep->arg[2]) == 1)
+					t->Message(0, "You have gained 1 practice!");
+				else
+					t->Message(0, "You have gained %i practices!", atoi(sep->arg[2]));
+			}
+		}
+		else if ((strcasecmp( sep->arg[1], "set" ) == 0 ) && (sep->IsNumber(2)))
+		{
+			if ((atoi(sep->arg[2]) < 0) || (atoi(sep->arg[2]) > 5000))
+				c->Message(0, "Error: #practices: set <value> must range from 0 to 5000.");
+			else
+			{
+				t->SetPractices(atoi(sep->arg[2]));
+				t->Save();
+				t->Message(0, "Your total practices have been set to %i.", atoi(sep->arg[2]));
+			}
+		}
+		else
+			c->Message(0, "Usage: #practices <add|set> <value>");
+	}
+	else
+		c->Message(0, "Error: #practices: Target must be a player.");
+}
+
 #ifdef BUGTRACK
 void command_bug(Client *c, const Seperator *sep)
 {
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:15 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3