Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Bots

Development::Bots Forum for bots.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2013, 01:18 PM
zippzipp
Fire Beetle
 
Join Date: Dec 2012
Posts: 14
Default Bot Quests for the Bot Creation Limit

Hi guys here is something I implemented on my server it moves the bot creation limit to be optionally controlled by a bot creation quest much like the bot spawn quest.

Add the following to bot.h
Code:
// bot.h 
static uint32 AllowedBotCreates(uint32 botOwnerCharacterID, std::string* errorMessage);

Replace this in bot.cpp:
Code:
// bot.cpp

// REPLACE: 
int32 MaxBotCreate = RuleI(Bots, CreateBotCount);
if(CreatedBotCount(c->CharacterID(), &TempErrorMessage) >= MaxBotCreate) {
	c->Message(0, "You cannot create more than %i bots.", MaxBotCreate);
	return;
}
With this: in bot.cpp
Code:
// WITH THIS:
int createBotCount = CreatedBotCount(c->CharacterID(), &TempErrorMessage);
if(RuleB(Bots, BotCreateQuest)) {
	const int allowedBots = AllowedBotCreates(c->CharacterID(), &TempErrorMessage);

	if(!TempErrorMessage.empty()) {
		c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
		return;
	}

	if(allowedBots == 0) {
		c->Message(0, "You cannot create any bots.");
		return;
	}

	if(createBotCount >= allowedBots) {
		c->Message(0, "You cannot create more than %i bots.", createBotCount);
		return;
	}
} else {
	int32 MaxBotCreate = RuleI(Bots, CreateBotCount);
	if(createBotCount >= MaxBotCreate) {
		c->Message(0, "You cannot create more than %i bots.", MaxBotCreate);
		return;
	}
}
Add this to bots.cpp
Code:
// bots.cpp
uint32 Bot::AllowedBotCreates(uint32 botOwnerCharacterID, std::string* errorMessage) {
	uint32 Result = 0;

	if(botOwnerCharacterID > 0) {
		char ErrBuf[MYSQL_ERRMSG_SIZE];
		char* Query = 0;
		MYSQL_RES* DatasetResult;
		MYSQL_ROW DataRow;

		if(database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT value FROM quest_globals WHERE name='bot_create_limit' and charid=%i", botOwnerCharacterID), ErrBuf, &DatasetResult)) {
			if(mysql_num_rows(DatasetResult) == 1) {
				DataRow = mysql_fetch_row(DatasetResult);
				if(DataRow)
					Result = atoi(DataRow[0]);
			}

			mysql_free_result(DatasetResult);
		}
		else
			*errorMessage = std::string(ErrBuf);

		safe_delete_array(Query);
	}

	return Result;
}
ADD this to ruletypes.h in the #ifdef BOTS section
Code:
// ruletypes.h
RULE_BOOL ( Bots, BotCreateQuest, false)
ADD this to questmgr.h in the #ifdef BOTS section
Code:
// questmgr.h
bool botcreatequest();
ADD this to questmgr.cpp
Code:
// questmgr.cpp

bool QuestManager::botcreatequest()
{
	return RuleB(Bots, BotCreateQuest);
}
ADD this to the QuestManager::createBot function in questmgr.cpp
Code:
// questmgr.cpp
if(RuleB(Bots, BotCreateQuest)){
	MaxBotCreate = Bot::AllowedBotCreates(initiator->CharacterID(), &TempErrorMessage);
}

There you have it. You also need to add a Rule to the db
Code:
INSERT INTO `peqdb`.`rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES ('1', 'Bots:BotCreateQuest', 'true', '');
Now bot creation can be controlled on a per character basis with the qglobal bot_create_limit
Reply With Quote
  #2  
Old 02-01-2013, 01:51 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I'd make a diff/patch using TortoiseSVN. Otherwise you may get a slew of questions and/or complaints that 'this doesn't work' due to those that do not properly apply the changes as you have them written. Just a recommendation of course.
Reply With Quote
  #3  
Old 02-01-2013, 06:50 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

Just a style thing, it would be better to use a reference rather than a pointer for your error message string.
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 11:36 PM.


 

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