[Patch] /lootcorpse, /motd and /random

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
User avatar
Rhas
Retired
Posts: 33
Joined: Sat May 29, 2010 11:39 am
Location: Kansas City

[Patch] /lootcorpse, /motd and /random

Post by Rhas » Sat Jun 05, 2010 1:08 pm

This patch implements the three commands above. I tried to get /assist working as well but am having issues getting the target refreshed in the client ui, so I figure I'd just release these three as they are working for me.

Commands.cpp

Code: Select all

--- Commands.cpp (rev 440)
+++ Commands.cpp (working copy)
@@ -18,6 +18,7 @@
 along with EQ2Emulator.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "Commands.h"
+#include "ClientPacketFunctions.h"
 #include "../common/version.h"
 #include "../common/seperator.h"
 #include "../common/servertalk.h"
@@ -1574,14 +1575,20 @@
 				client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
 			break;
 									 }
+		case COMMAND_LOOT_CORPSE:
 		case COMMAND_LOOT:{
 			Spawn* target = client->GetPlayer()->GetTarget();
 			if(target && target->IsEntity()){
-				client->Loot((Entity*)target);
-				if(!((Entity*)target)->HasLoot()){
-					if(((Entity*)target)->IsNPC())
-						client->GetCurrentZone()->RemoveDeadSpawn(target);
+				if(target->GetDistance(client->GetPlayer()) <= 10){
+					client->Loot((Entity*)target);
+					if(!((Entity*)target)->HasLoot()){
+						if(((Entity*)target)->IsNPC())
+							client->GetCurrentZone()->RemoveDeadSpawn(target);
+					}
 				}
+				else
+					client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
+				
 			}
 			else if(!target || target->GetHP() > 0)
 				client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
@@ -4000,7 +4007,31 @@
 					client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
 			}
 			break;
+		}		
+		case COMMAND_MOTD:{
+			if(client)
+				ClientPacketFunctions::SendMOTD(client);
+					
+			break;
 		}
+		case COMMAND_RANDOM:{	
+			char message[256] = {0};			
+			if(sep)
+			{
+				if(sep->GetArgNumber() == 0 && sep->IsNumber(0))
+					sprintf(message, "Random: %s rolls from 1 to %u on the magic dice...and scores a %u!", client->GetPlayer()->GetName(), atoul(sep->arg[0]), MakeRandomInt(1, atoul(sep->arg[0])));
+				else if(sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
+					sprintf(message, "Random: %s rolls from %u to %u on the magic dice...and scores a %u!", client->GetPlayer()->GetName(), atoul(sep->arg[0]), atoul(sep->arg[1]), MakeRandomInt(atoul(sep->arg[0]), atoul(sep->arg[1])));
+				else
+					sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %u!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
+			}
+			else
+				sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %u!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
+			
+			client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);									
+			break;
+		}		
+
 		default:{
 			LogFile->write(EQEMuLog::Status, "Unhandled command: %s", command->command.data.c_str());
 				}
Commands.h

Code: Select all

--- Commands.h (rev 440)
+++ Commands.h	(working copy)
@@ -479,4 +479,7 @@
 #define COMMAND_LOCATION_LIST		274
 #define COMMAND_USE_EQUIPPED_ITEM	275
 #define COMMAND_CANCEL_MAINTAINED	276
+#define COMMAND_LOOT_CORPSE			277
+#define	COMMAND_MOTD				278
+#define COMMAND_RANDOM				279
 #endif

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: [Patch] /lootcorpse, /motd and /random

Post by Zcoretri » Sat Jun 05, 2010 4:19 pm

I'll get this added in shortly...thanks for the submission :mrgreen:

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests