PDA

View Full Version : BotOwner by AccountID instead of CharacterID


skyy
10-12-2015, 03:26 PM
I am currently looking for a way to get bots to spawn if the accountID matches instead of the characterID and came to a bit of a pit regarding my meager knowledge of the source.

What i tried was looking into bots.cpp:

1) at the spawn command I disabled the check for owned bot:
if(!strcasecmp(sep->arg[1], "spawn") ) {
if (RuleB(Bots, BotCharacterLevelEnabled)) {
if (c->GetLevel() < RuleI(Bots, BotCharacterLevel)) {
c->Message(0, "You are only level %d, you must be level %d to spawn a bot!", c->GetLevel(), RuleI(Bots, BotCharacterLevel));
return;
}
}

uint32 botId = GetBotIDByBotName(std::string(sep->arg[2]));
int xy = c->AccountID();
int yz = GetBotOwnerCharacterID(botId, &TempErrorMessage);
int yzz = database.GetAccountIDByChar(yz);
if (xy != yzz)//(GetBotOwnerCharacterID(botId, &TempErrorMessage) != c->CharacterID()) godrage
{
c->Message(0, "You can't spawn a bot that you don't own.");

}

2) disabling the same check at the Bot::Spawn
void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
if(GetBotID() > 0 && _botOwnerCharacterID > 0 && botCharacterOwner )//&& botCharacterOwner->CharacterID() == _botOwnerCharacterID)

3) redoing the casttoclient to the actual client
if(this->Save())
botCharacterOwner->CastToClient()->Message(0, "%s saved.", this->GetCleanName());
//this->GetBotOwner()->CastToClient()->Message(0, "%s saved.", this->GetCleanName());
else
botCharacterOwner->CastToClient()->Message(13, "%s save failed!", this->GetCleanName());
//this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName());

4) now the bot spawns and immediately despawns and I am stuck as to where the despawn is triggered


can anyone see this endeavour as totally fruitless ?

The main idea for my solo server project is to not have to create bots for every character you create over and over again.

thanks in advance!

Uleat
10-12-2015, 03:49 PM
This one is a little more involved than the other and I'm in the middle of an implementation review.


My guess on the despawn is that something is askew with the instantiated bot..probably not having an owner id..and the it is being marked
and processed for de-pop.


If I get time, I'll come back to this.

skyy
10-12-2015, 03:52 PM
would be great, thanks :)

in the long run i could see this as a candidate for rule_values

Noport
10-12-2015, 05:21 PM
if (xy.equals(yz) && yz.equals(yzz)); True
else if
yzz.equals(null); False You can't spawn a bot that you don't own.

skyy
10-14-2015, 01:32 PM
This one is a little more involved than the other and I'm in the middle of an implementation review.


My guess on the despawn is that something is askew with the instantiated bot..probably not having an owner id..and the it is being marked
and processed for de-pop.


If I get time, I'll come back to this.

id love to look into it, just dont know where to start looking for the being marked/process for depop - any pointers ? :)