rencro
11-08-2013, 09:41 PM
There are always many ways to accomplish things with code, here is my solution for bots:
Note, dont use this diff, I have edited it just to give you an idea, as I have actually removed much more than just create...
diff --git a/zone/bot.cpp b/zone/bot.cpp
index 87f9151..a117a5a 100644
--- a/zone/bot.cpp
+++ b/zone/bot.cpp
@@ -11655,36 +11655,14 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
if(!strcasecmp( sep->arg[1], "help") && !strcasecmp( sep->arg[2], "\0")){
c->Message(0, "List of commands availables for bots :");
c->Message(0, "#bot help - show this");
- c->Message(0, "#bot create [name] [class (id)] [race (id)] [model (male/female)] - create a permanent bot. See #bot help create.");
- c->Message(0, "#bot help create - show all the race/class id. (make it easier to create bots)");
- c->Message(0, "#bot delete - completely destroy forever the targeted bot and all its items.");
c->Message(0, "#bot list [all/class(1-16)] - list your bots all or by class. Classes: 1(Warrior), 2(Cleric), 3(Paladin), 4(Ranger), 5(Sk), 6(Druid), 7(Monk), 8(Bard), 9(Rogue), 10(Shaman), 11(Necro), 12(Wiz), 13(Mag), 14(Ench), 15(Beast), 16(Bersek)");
c->Message(0, "#bot spawn [bot name] - spawn a bot from it's name (use list to see all the bots). ");
c->Message(0, "#bot inventory list - show the inventory (and the slots IDs) of the targetted bot.");
c->Message(0, "#bot inventory remove [slotid] - remove the item at the given slot in the inventory of the targetted bot.");
c->Message(0, "#bot update - you must type that command once you gain a level.");
c->Message(0, "#bot summon - It will summon your targeted bot to you.");
- c->Message(0, "#bot ai mez - If you're grouped with an enchanter, he will mez your target.");
- c->Message(0, "#bot picklock - You must have a targeted rogue bot in your group and be right on the door.");
c->Message(0, "#bot cure [poison|disease|curse|blindness] Cleric has most options");
- c->Message(0, "#bot bindme - You must have a Cleric in your group to get Bind Affinity cast on you.");
- c->Message(0, "#bot track - look at mobs in the zone (ranger has options)");
- c->Message(0, "#bot target calm - attempts to pacify your target mob.");
- c->Message(0, "#bot evac - transports your pc group to safe location in the current zone. bots are lost");
- c->Message(0, "#bot resurrectme - Your bot Cleric will rez you.");
- c->Message(0, "#bot corpse summon - Necromancers summon corpse.");
- c->Message(0, "#bot lore - cast Identify on the item on your mouse pointer.");
- c->Message(0, "#bot sow - Bot sow on you (Druid has options)");
- c->Message(0, "#bot invis - Bot invisiblity (must have proper class in group)");
- c->Message(0, "#bot levitate - Bot levitation (must have proper class in group)");
- c->Message(0, "#bot resist - Bot resist buffs (must have proper class in group)");
- c->Message(0, "#bot runeme - Enchanter Bot cast Rune spell on you");
- c->Message(0, "#bot shrink - Shaman or Beastlord will shrink target");
- c->Message(0, "#bot endureb - Bot enduring breath (must have proper class in group)");
- c->Message(0, "#bot charm - (must have proper class in group)");
- c->Message(0, "#bot dire charm - (must have proper class in group)");
- c->Message(0, "#bot pet remove - (remove pet before charm)");
- c->Message(0, "#bot gate - you need a Druid or Wizard in your group)");
+ //c->Message(0, "#bot runeme - Enchanter Bot cast Rune spell on you");
c->Message(0, "#bot archery - Toggle Archery Skilled bots between using a Bow or using Melee weapons.");
c->Message(0, "#bot magepet [earth|water|air|fire|monster] - Select the pet type you want your Mage bot to use.");
c->Message(0, "#bot giveitem - Gives your targetted bot the item you have on your cursor.");
@@ -11847,117 +11776,6 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
return;
}
- if(!strcasecmp(sep->arg[1], "create")) {
- if(sep->arg[2][0] == '\0' || sep->arg[3][0] == '\0' || sep->arg[4][0] == '\0' || sep->arg[5][0] == '\0' || sep->arg[6][0] != '\0') {
- c->Message(0, "Usage: #bot create [name] [class(id)] [race(id)] [gender (male/female)]");
- return;
- }
- else if(strcasecmp(sep->arg[3],"1") && strcasecmp(sep->arg[3],"2") && strcasecmp(sep->arg[3],"3") && strcasecmp(sep->arg[3],"4") && strcasecmp(sep->arg[3],"5") && strcasecmp(sep->arg[3],"6") && strcasecmp(sep->arg[3],"7") && strcasecmp(sep->arg[3],"8") && strcasecmp(sep->arg[3],"9") && strcasecmp(sep->arg[3],"10") && strcasecmp(sep->arg[3],"11") && strcasecmp(sep->arg[3],"12") && strcasecmp(sep->arg[3],"13") && strcasecmp(sep->arg[3],"14") && strcasecmp(sep->arg[3],"15") && strcasecmp(sep->arg[3],"16")) {
- c->Message(0, "Usage: #bot create [name] [class(id)] [race(id)] [gender (male/female)]");
- return;
- }
- else if(strcasecmp(sep->arg[4],"1") && strcasecmp(sep->arg[4],"2") && strcasecmp(sep->arg[4],"3") && strcasecmp(sep->arg[4],"4") && strcasecmp(sep->arg[4],"5") && strcasecmp(sep->arg[4],"6") && strcasecmp(sep->arg[4],"7") && strcasecmp(sep->arg[4],"8") && strcasecmp(sep->arg[4],"9") && strcasecmp(sep->arg[4],"10") && strcasecmp(sep->arg[4],"11") && strcasecmp(sep->arg[4],"12") && strcasecmp(sep->arg[4],"330") && strcasecmp(sep->arg[4],"128") && strcasecmp(sep->arg[4],"130") && strcasecmp(sep->arg[4],"522")) {
- c->Message(0, "Usage: #bot create [name] [class(1-16)] [race(1-12,128,130,330,522)] [gender (male/female)]");
- return;
- }
- else if(strcasecmp(sep->arg[5],"male") && strcasecmp(sep->arg[5],"female")) {
- c->Message(0, "Usage: #bot create [name] [class(1-16)] [race(1-12,128,130,330,522)] [gender (male/female)]");
- return;
- }
-
- uint32 MaxBotCreate = RuleI(Bots, CreateBotCount);
- if(CreatedBotCount(c->CharacterID(), &TempErrorMessage) >= MaxBotCreate) {
- c->Message(0, "You cannot create more than %i bots.", MaxBotCreate);
- return;
- }
-
- if(!TempErrorMessage.empty()) {
- c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
- return;
- }
-
- int gender = 0;
- if(!strcasecmp(sep->arg[5], "female"))
- gender = 1;
-
- NPCType DefaultNPCTypeStruct = CreateDefaultNPCTypeStructForBot(std::string(sep->arg[2]), std::string(), c->GetLevel(), atoi(sep->arg[4]), atoi(sep->arg[3]), gender);
- Bot* NewBot = new Bot(DefaultNPCTypeStruct, c);
-
- if(NewBot) {
- if(!NewBot->IsValidRaceClassCombo()) {
- c->Message(0, "That Race/Class combination cannot be created.");
- return;
- }
-
- if(!NewBot->IsValidName()) {
- c->Message(0, "%s has invalid characters. You can use only the A-Z, a-z and _ characters in a bot name.", NewBot->GetCleanName());
- return;
- }
-
- if(!NewBot->IsBotNameAvailable(&TempErrorMessage)) {
- c->Message(0, "The name %s is already being used. Please choose a different name.", NewBot->GetCleanName());
- return;
- }
-
- if(!TempErrorMessage.empty()) {
- c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
- return;
- }
-
- // Now that all validation is complete, we can save our newly created bot
- if(!NewBot->Save())
- c->Message(0, "Unable to save %s as a bot.", NewBot->GetCleanName());
- else
- c->Message(0, "%s saved as bot %u.", NewBot->GetCleanName(), NewBot->GetBotID());
- }
- else {
- // TODO: Log error message here
- }
-
- // Bot creation is complete
- return;
- }
-
- if(!strcasecmp(sep->arg[1], "help") && !strcasecmp(sep->arg[2], "create") ){
- c->Message(0, "Classes: 1(Warrior), 2(Cleric), 3(Paladin), 4(Ranger), 5(Sk), 6(Druid), 7(Monk), 8(Bard), 9(Rogue), 10(Shaman), 11(Necro), 12(Wiz), 13(Mag), 14(Ench), 15(Beast), 16(Bersek)");
- c->Message(0, "------------------------------------------------------------------");
- c->Message(0, "Races: 1(Human), 2(Barb), 3(Erudit), 4(Wood elf), 5(High elf), 6(Dark elf), 7(Half elf), 8(Dwarf), 9(Troll), 10(Ogre), 11(Halfling), 12(Gnome), 128(Iksar), 130(Vah shir), 330(Froglok), 522(Drakkin)");
- c->Message(0, "------------------------------------------------------------------");
- c->Message(0, "Usage: #bot create [name] [class(1-16)] [race(1-12,128,130,330,522)] [gender(male/female)]");
- c->Message(0, "Example: #bot create Sneaky 9 6 male");
- return;
- }
-
- if(!strcasecmp(sep->arg[1], "delete") ) {
- if((c->GetTarget() == nullptr) || !c->GetTarget()->IsBot())
- {
- c->Message(15, "You must target a bot!");
- return;
- }
- else if(c->GetTarget()->CastToBot()->GetBotOwnerCharacterID() != c->CharacterID())
- {
- c->Message(15, "You can't delete a bot that you don't own.");
- return;
- }
-
- if(c->GetTarget()->IsBot()) {
- Bot* BotTargeted = c->GetTarget()->CastToBot();
-
- if(BotTargeted) {
- BotTargeted->DeleteBot(&TempErrorMessage);
-
- if(!TempErrorMessage.empty()) {
- c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
- return;
- }
-
- BotTargeted->Camp(false);
- }
- }
-
- return;
- }
-
if(!strcasecmp(sep->arg[1], "list")) {
bool listAll = true;
int iClass = atoi(sep->arg[2]);
You can then use a quest to get your bots created, even using qglobals to award them ect, skys the limit
quest::createBot("$name''s Fighter", "Fighter Bot",1,1,1,0);
Definition for createBot:
bool createBot(const char *name, const char *lastname, uint8 level, uint16 race, uint8 botclass, uint8 gender);
rencro
11-09-2013, 01:03 AM
Sorry bout that, you can use this method that keeps everything but just adds a rule:
in zone/bot.cpp
AT
void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
// All bot command processing occurs here now instead of in command.cpp
// TODO: Log any possible error messages as most of these will be MySQL error messages.
std::string TempErrorMessage;
if(sep->arg[1][0] == '\0') {
c->Message(13, "Bad argument, type #bot help");
ADD
void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
// All bot command processing occurs here now instead of in command.cpp
// TODO: Log any possible error messages as most of these will be MySQL error messages.
std::string TempErrorMessage;
int16 BotMinStatus = (RuleI(Bots, BotMinStatus)); // min status to do various bot commands
if(sep->arg[1][0] == '\0') {
c->Message(13, "Bad argument, type #bot help");
Then at whatever commands you want to be subject to new custom rule add"
if(c->Admin() < BotMinStatus) {
c->Message(0, "Sorry, your status is to low to use this command");
return;
}
and be sure to make the if you inserted in front of an else if. Example
in zone/bot.cpp
if(!strcasecmp(sep->arg[1], "create")) {
if(sep->arg[2][0] == '\0' || sep->arg[3][0] == '\0' || sep->arg[4][0] == '\0' || sep->arg[5][0] == '\0' || sep->arg[6][0] != '\0') {
c->Message(0, "Usage: #bot create [name] [class(id)] [race(id)] [gender (male/female)]");
return;
}
CHANGE TO --
if(!strcasecmp(sep->arg[1], "create")) {
if(c->Admin() < BotMinStatus) {
c->Message(0, "Sorry, your status is to low to use this command");
return;
}
else if(sep->arg[2][0] == '\0' || sep->arg[3][0] == '\0' || sep->arg[4][0] == '\0' || sep->arg[5][0] == '\0' || sep->arg[6][0] != '\0') {
c->Message(0, "Usage: #bot create [name] [class(id)] [race(id)] [gender (male/female)]");
return;
}
common/ruletypes.h
AT--
#ifdef BOTS
RULE_CATEGORY ( Bots )
RULE_REAL ( Bots, BotManaRegen, 2.0 ) // Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.
RULE_BOOL ( Bots, BotFinishBuffing, false ) // Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.
RULE_INT ( Bots, CreateBotCount, 150 ) // Number of bots that each account can create
RULE_INT ( Bots, SpawnBotCount, 71 ) // Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid
RULE_BOOL ( Bots, BotQuest, false ) // Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl
RULE_BOOL ( Bots, BotGroupBuffing, false ) // Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.
RULE_BOOL ( Bots, BotSpellQuest, false ) // Anita Thrall's (Anita_Thrall.pl) Bot Spell Scriber quests.
RULE_INT ( Bots, BotAAExpansion, 8 ) // Bots get AAs through this expansion
RULE_BOOL ( Bots, BotGroupXP, false ) // Determines whether client gets xp for bots outside their group.
RULE_BOOL ( Bots, BotBardUseOutOfCombatSongs, true) // Determines whether bard bots use additional out of combat songs.
RULE_CATEGORY_END()
#endif
CHANGE TO --
#ifdef BOTS
RULE_CATEGORY ( Bots )
RULE_REAL ( Bots, BotManaRegen, 2.0 ) // Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.
RULE_BOOL ( Bots, BotFinishBuffing, false ) // Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.
RULE_INT ( Bots, CreateBotCount, 150 ) // Number of bots that each account can create
RULE_INT ( Bots, SpawnBotCount, 71 ) // Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid
RULE_BOOL ( Bots, BotQuest, false ) // Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl
RULE_BOOL ( Bots, BotGroupBuffing, false ) // Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.
RULE_BOOL ( Bots, BotSpellQuest, false ) // Anita Thrall's (Anita_Thrall.pl) Bot Spell Scriber quests.
RULE_INT ( Bots, BotAAExpansion, 8 ) // Bots get AAs through this expansion
RULE_BOOL ( Bots, BotGroupXP, false ) // Determines whether client gets xp for bots outside their group.
RULE_BOOL ( Bots, BotBardUseOutOfCombatSongs, true ) // Determines whether bard bots use additional out of combat songs.
RULE_INT ( Bots, BotMinStatus, 0 ) // add custom rules to various bot commands to limit via status level
RULE_CATEGORY_END()
#endif
Note I simply added a space to the previous BotBardUseOutOfCombatSongs to keep everything looking similar at the end..
Then just create your sql rule:
INSERT INTO rule_values VALUES ('1', 'Bots:BotMinStatus', '255', 'Min status to access various customized bot commands.');
And the quest still work on status 0 characters..
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.