ArcEmu: [Core Patch] Housing System - WIP - Usable Release - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Core Patch] Housing System - WIP - Usable Release

#1 User is offline   tekkeryole 

  • Member
  • Pip
  • Group: Members
  • Posts: 25
  • Joined: 01-August 08

Posted 19 September 2009 - 10:15 PM

Ok, Ochagos from ACWEB asked me for some kind of a usable script for my older Guild House system.
For this version I decided to go with simplicity and stability. This version supports ArcEmu but can easily be ported into another emulator with some work.

We'll start out with an easy buy / delete / port command. This is all done in the core for
more stability btw peeps. So if ya'll can't use a patch file, please dont post your questions
here. If you have tortoise svn, and you know how to update and checkout, then you should know
how to patch by now.

Ok, first off we will start out with something easy, for instance I will be using the .recall
command table. We will only be using the ADD / DEL and PORT functions of this set. The rest
or any other fixes can be done by you or the community.

Core Patch - Diff pastebin - collaborative debugging tool
(save as a .patch file)

HOUSE SQL

/*Table structure for table `recall` */

DROP TABLE IF EXISTS `house`;

CREATE TABLE `house` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `name` varchar(100) NOT NULL,
  `MapId` int(10) unsigned NOT NULL default '0',
  `positionX` float NOT NULL default '0',
  `positionY` float NOT NULL default '0',
  `positionZ` float NOT NULL default '0',
  `Orientation` float unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='House Command';

/*Data for the table `house` */

LOCK TABLES `house` WRITE;

UNLOCK TABLES;


What you need to add to this script is an actual buy function that checks and takes gold upon purchase. For now this is only something similar to the recall functions only for players. I'll add some more to this later on, but I'm sure more users in the community can do more to this then I can.

I have not tested this in game, but It compiles with revison 2907.

What can be done with this would be Sammy's suggestion and fill the House db with pre designated house areas that players can purchase and port to.

Index: arcemu-world/Chat.cpp
===================================================================
--- arcemu-world/Chat.cpp	(revision 2907)
+++ arcemu-world/Chat.cpp	(working copy)
 -59,6 +59,8 @@
 		return _petCommandTable;
 	else if(!stricmp(name, "recall"))
 		return _recallCommandTable;
+	else if(!stricmp(name, "house"))
+		return _houseCommandTable;
 	else if(!stricmp(name, "guild"))
 		return _GuildCommandTable;
 	else if(!stricmp(name, "gm"))
 -207,6 +209,7 @@
 	free( _honorCommandTable );
 	free( _petCommandTable );
 	free( _recallCommandTable );
+	free( _houseCommandTable );
 	free( _questCommandTable );
 	free( _serverCommandTable );
 	free( _gmCommandTable );
 -520,6 +523,15 @@
 	};
 	dupe_command_table(recallCommandTable, _recallCommandTable);
 
+	static ChatCommand houseCommandTable[] =
+	{
+		{ "buy",        '0', &ChatHandler::HandleHouseAddCommand,        "Buy a house location",       NULL, 0, 0, 0 },
+		{ "del",        '0', &ChatHandler::HandleHouseDelCommand,        "Remove a house location",  NULL, 0, 0, 0 },
+		{ "port",       '0', &ChatHandler::HandleHouseGoCommand,         "Teleports you to house location", NULL, 0, 0, 0 },
+		{ NULL,         '0', NULL,                                        "",                          NULL, 0, 0, 0 }
+	};
+	dupe_command_table(houseCommandTable, _houseCommandTable);
+
 	static ChatCommand questCommandTable[] =
 	{
 		{ "addboth",   '2', &ChatHandler::HandleQuestAddBothCommand,   "Add quest <id> to the targeted NPC as start & finish",      NULL, 0, 0, 0 },
 -732,6 +744,7 @@
 		{ "quest",           'q', NULL,                                                     "",                                                                                                                                        questCommandTable,        0, 0, 0 },
 		{ "pet",             'm', NULL,                                                     "",                                                                                                                                        petCommandTable,          0, 0, 0 },
 		{ "recall",          'q', NULL,                                                     "",                                                                                                                                        recallCommandTable,       0, 0, 0 },
+		{ "house",          '0', NULL,                                                     "",                                                                                                                                        houseCommandTable,       0, 0, 0 },
 		{ "guild",           'm', NULL,                                                     "",                                                                                                                                        GuildCommandTable,        0, 0, 0 },
 		{ "server",          '0', NULL,                                                     "",                                                                                                                                        serverCommandTable,       0, 0, 0 },
 		{ "character",       '0', NULL,                                                     "",                                                                                                                                        characterCommandTable,    0, 0, 0 },
Index: arcemu-world/Chat.h
===================================================================
--- arcemu-world/Chat.h	(revision 2907)
+++ arcemu-world/Chat.h	(working copy)
 -172,6 +172,7 @@
 	ChatCommand* _honorCommandTable;
 	ChatCommand* _petCommandTable;
 	ChatCommand* _recallCommandTable;
+	ChatCommand* _houseCommandTable;
 	ChatCommand* _questCommandTable;
 	ChatCommand* _serverCommandTable;
 	ChatCommand* _gmCommandTable;
 -525,6 +526,9 @@
 	bool HandleGlobalPlaySoundCommand(const char* args, WorldSession * m_session);
 	bool HandleRecallPortPlayerCommand(const char* args, WorldSession * m_session);
 	bool HandleRecallPortUsCommand(const char* args, WorldSession * m_session);
+	bool HandleHouseGoCommand(const char* args, WorldSession *m_session);
+	bool HandleHouseAddCommand(const char* args, WorldSession *m_session);
+	bool HandleHouseDelCommand(const char* args, WorldSession *m_session);
 
 	// Bans
 	bool HandleIPBanCommand(const char * args, WorldSession * m_session);
Index: arcemu-world/RecallCommands.cpp
===================================================================
--- arcemu-world/RecallCommands.cpp	(revision 2907)
+++ arcemu-world/RecallCommands.cpp	(working copy)
 -260,3 +260,139 @@
 	delete result;
 	return false;
 }
+
+bool GetHouseLocation(const char* location, uint32 &map, LocationVector &v)
+{
+	QueryResult *result = WorldDatabase.Query( "SELECT * FROM house ORDER BY name" );
+
+	if( result == NULL)
+		return false;
+
+	do
+	{
+		Field* fields = result->Fetch();
+		const char* locname = fields[1].GetString();
+		uint32 locmap = fields[2].GetUInt32();
+		float x = fields[3].GetFloat();
+		float y = fields[4].GetFloat();
+		float z = fields[5].GetFloat();
+		float o = fields[6].GetFloat();
+
+		if( strnicmp( const_cast< char* >( location ), locname, strlen( location ) ) == 0 )
+		{
+			map = locmap;
+			v.x = x;
+			v.y = y;
+			v.z = z;
+			v.o = o;
+			delete result;
+			return true;
+		}
+
+	}while (result->NextRow());
+
+	delete result;
+	return false;
+
+}
+
+bool ChatHandler::HandleHouseGoCommand(const char* args, WorldSession *m_session)
+{
+	if( args == NULL )
+		return false;
+
+	if( !*args )
+		return false;
+
+	if( m_session == NULL )
+		return false;
+
+	uint32 map;
+	LocationVector v;
+	if (GetHouseLocation(args, map, v))
+	{
+		if( m_session->GetPlayer() != NULL )
+		{
+			m_session->GetPlayer()->SafeTeleport(map, 0, v);
+			return true;
+		}
+		return false;
+	}
+	return false;
+}
+
+bool ChatHandler::HandleHouseAddCommand(const char* args, WorldSession *m_session)
+{
+	if(!*args)
+		return false;
+	
+	QueryResult *result = WorldDatabase.Query( "SELECT name FROM house" );
+	if(!result)
+		return false;
+	do
+	{
+		Field *fields = result->Fetch();
+		const char * locname = fields[0].GetString();
+		if (strncmp((char*)args,locname,strlen(locname))==0)
+		{
+			RedSystemMessage(m_session, "Name in use, please use another name for your location.");
+			delete result;
+			return true;
+		}
+	}while (result->NextRow());
+	delete result;
+
+	Player* plr = m_session->GetPlayer();
+	std::stringstream ss;
+	
+	string rc_locname = string(args);
+
+	ss << "INSERT INTO house (name, mapid, positionX, positionY, positionZ, Orientation) VALUES ('"
+	<< WorldDatabase.EscapeString(rc_locname).c_str() << "' , "
+	<< plr->GetMapId()     << ", "
+	<< plr->GetPositionX() << ", " 
+	<< plr->GetPositionY() << ", "
+	<< plr->GetPositionZ() << ", "
+	<< plr->GetOrientation() << ");";
+	WorldDatabase.Execute( ss.str( ).c_str( ) );
+
+	char buf[256]; 
+	snprintf((char*)buf, 256, "Added location to DB with MapID: %d, X: %f, Y: %f, Z: %f, O: %f",
+		(unsigned int)plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
+	GreenSystemMessage(m_session, buf);
+	sGMLog.writefromsession(m_session, "used house add, added \"%s\" location to database.", rc_locname.c_str());
+
+	return true;
+}
+
+bool ChatHandler::HandleHouseDelCommand(const char* args, WorldSession *m_session)
+{
+	   if(!*args)
+		return false;
+
+	QueryResult *result = WorldDatabase.Query( "SELECT id,name FROM house" );
+	if(!result)
+		return false;
+
+	do
+	{
+		Field *fields = result->Fetch();
+		float id = fields[0].GetFloat();
+		const char * locname = fields[1].GetString();
+
+		if (strnicmp((char*)args,locname,strlen(locname))==0)
+		{
+			std::stringstream ss;
+			ss << "DELETE FROM house WHERE id = "<< (int)id <<";";
+			WorldDatabase.Execute( ss.str( ).c_str( ) );
+			GreenSystemMessage(m_session, "House location removed.");
+			sGMLog.writefromsession(m_session, "used house delete, removed \"%s\" location from database.", args);
+			delete result;
+			return true;
+		}
+
+	}while (result->NextRow());
+
+	delete result;
+	return false;
+}
\ No newline at end of file

0

#2 User is offline   artus 

  • Newbie
  • Group: Members
  • Posts: 1
  • Joined: 07-October 08

Posted 09 December 2009 - 02:12 PM

hi,

i have tested the script...i can type ingame .house buy but nothing happens...i hope you can add more features soon xd
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users