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

Development::Bots Forum for bots.

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2015, 03:30 PM
skyy's Avatar
skyy
Fire Beetle
 
Join Date: Sep 2015
Posts: 15
Default Limit Bot Class Count per Group

Hello there,

i am currently trying to limit the amount of same class-bots per group for my solo server project and am having a little trouble doing so.

what i was trying was to simply not let them being invited to group when there is already the same class present:
Code:
void Bot::ProcessBotGroupInvite(Client* c, std::string botName) {
	if(c) {
		Bot* invitedBot = GetBotByBotClientOwnerAndBotName(c, botName);

		if(invitedBot && !invitedBot->HasGroup()) {
			if(!c->IsGrouped()) {
				Group *g = new Group(c);
				if(AddBotToGroup(invitedBot, g)) {
					entity_list.AddGroup(g);
					database.SetGroupLeaderName(g->GetID(), c->GetName());
					g->SaveGroupLeaderAA();
					database.SetGroupID(c->GetName(), g->GetID(), c->CharacterID());
					database.SetGroupID(invitedBot->GetCleanName(), g->GetID(), invitedBot->GetBotID());
				}
			} else {
				// godrage
				//for (int i = 0; i < 7; ++i)
				//{
				//	if (c->GetGroup()->members[i]->GetClass() == invitedBot->GetClass())
				//	{
				//		c->Say("It's all about diversity...");
				//		break;
				//	}
				//}
								
				AddBotToGroup(invitedBot, c->GetGroup());
				database.SetGroupID(invitedBot->GetCleanName(), c->GetGroup()->GetID(), invitedBot->GetBotID());
			}
		}
	}
}
but due to my rather limited knowledge of the source and c++ i cant seem to get it to work;

anyone able to help me out on that ? would highly appreciate it
Reply With Quote
  #2  
Old 10-12-2015, 03:44 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

I'm assuming that it's crashing, or at least letting the bot in?


As far as the code..try this:
Code:
void Bot::ProcessBotGroupInvite(Client* c, std::string botName) {
	if(c) {
		Bot* invitedBot = GetBotByBotClientOwnerAndBotName(c, botName);

		if(invitedBot && !invitedBot->HasGroup()) {
			if(!c->IsGrouped()) {
				Group *g = new Group(c);
				if(AddBotToGroup(invitedBot, g)) {
					entity_list.AddGroup(g);
					database.SetGroupLeaderName(g->GetID(), c->GetName());
					g->SaveGroupLeaderAA();
					database.SetGroupID(c->GetName(), g->GetID(), c->CharacterID());
					database.SetGroupID(invitedBot->GetCleanName(), g->GetID(), invitedBot->GetBotID());
				}
			} else {
				// godrage
				for (int i = 0; i < 6; ++i)
				{
					if (!c->GetGroup()->members[i])
						continue;
						
					if (c->GetGroup()->members[i]->GetClass() == invitedBot->GetClass())
					{
						c->Say("It's all about diversity...");
						return;
					}
				}
								
				AddBotToGroup(invitedBot, c->GetGroup());
				database.SetGroupID(invitedBot->GetCleanName(), c->GetGroup()->GetID(), invitedBot->GetBotID());
			}
		}
	}
}

That's off the cuff..so, I don't know if it works.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #3  
Old 10-12-2015, 03:45 PM
skyy's Avatar
skyy
Fire Beetle
 
Join Date: Sep 2015
Posts: 15
Default

thanks, gonna try it
Reply With Quote
  #4  
Old 10-13-2015, 07:28 AM
skyy's Avatar
skyy
Fire Beetle
 
Join Date: Sep 2015
Posts: 15
Default

it works perfectly and in case someone is looking to do the same, thats what my code looks like atm:

Code:
void Bot::ProcessBotGroupInvite(Client* c, std::string botName) {
	if(c) {
		Bot* invitedBot = GetBotByBotClientOwnerAndBotName(c, botName);

		if(invitedBot && !invitedBot->HasGroup()) {
			if(!c->IsGrouped()) {
				//godrage
				if (c->GetClass() == invitedBot->GetClass())
					{
						//c->Say("It's all about diversity... and against clones");
						invitedBot->Say("There is already someone with my talents in your group.");
						invitedBot->Emote("rejects your invitations");
						return;
					}
				//godrage
				Group *g = new Group(c);
				if(AddBotToGroup(invitedBot, g)) {
					entity_list.AddGroup(g);
					database.SetGroupLeaderName(g->GetID(), c->GetName());
					g->SaveGroupLeaderAA();
					database.SetGroupID(c->GetName(), g->GetID(), c->CharacterID());
					database.SetGroupID(invitedBot->GetCleanName(), g->GetID(), invitedBot->GetBotID());
					BotGroupOrderFollow(g,c); //godrage
				}
			} else {
				 //godrage
				for (int i = 0; i < 6; ++i)
				{
					if (!c->GetGroup()->members[i])
						continue;
					if (c->GetGroup()->members[i]->GetClass() == invitedBot->GetClass())
					{
						//c->Say("It's all about diversity... and against clones");
						invitedBot->Say("There is already someone with my talents in your group.");
						invitedBot->Emote("rejects your invitations");
						return;
					}
				}
				//godrage
				Group *gg = c->GetGroup(); //godrage
				AddBotToGroup(invitedBot, c->GetGroup());
				database.SetGroupID(invitedBot->GetCleanName(), c->GetGroup()->GetID(), invitedBot->GetBotID());
				BotGroupOrderFollow(gg, c); //godrage
			}
		}
	}
}



the reason for
Code:
BotGroupOrderFollow(g,c); //godrage
is simply the fact that i add a different followdistance for each bot with the follow command which i now trigger from the invite.

my personal reason for this change is to simply enforce a policy to see bots as dearly beloved group members and not as zerg fodder
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:57 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