View Single Post
  #4  
Old 11-08-2013, 09:41 PM
rencro
Hill Giant
 
Join Date: Sep 2008
Location: So. California
Posts: 219
Default

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...

Code:
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

Code:
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);
Reply With Quote