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

Development::Bots Forum for bots.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 12-28-2009, 04:32 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Here's the code:

zone/bot.cpp
Code:
	if(!strcasecmp(sep->arg[1], "archery")) {
		if((c->GetTarget() == NULL) || (c->GetTarget() == c) || !c->GetTarget()->IsBot()) {
			c->Message(15, "You must target a bot!");
			return;
		}

		Mob *archerbot = c->GetTarget();
		if((archerbot->GetClass()==WARRIOR)||(archerbot->GetClass()==PALADIN)||(archerbot->GetClass()==RANGER)||(archerbot->GetClass()==SHADOWKNIGHT)||(archerbot->GetClass()==ROGUE)) {
			//const Item_Struct* botweapon = database.GetItem(archerbot->CastToBot()->GetItem(SLOT_RANGE));
			const Item_Struct* botweapon = database.GetItem(archerbot->CastToBot()->GetItem(SLOT_RANGE)->item_id);
			uint32 archeryMaterial;
			uint32 archeryColor;
			uint32 archeryBowID;
			uint32 archeryAmmoID;
			uint32 range = 0;
			if(botweapon && (botweapon->ItemType == ItemTypeBow)) {
				archeryMaterial = atoi(botweapon->IDFile+2);
				archeryBowID = botweapon->ID;
				archeryColor = botweapon->Color;
				range =+ botweapon->Range;
				botweapon = database.GetItem(archerbot->CastToNPC()->GetItem(SLOT_AMMO)->item_id);
				if(!botweapon || (botweapon->ItemType != ItemTypeArrow)) {
					archerbot->Say("I don't have any arrows.");
					archerbot->CastToBot()->SetBotArcheryRange(0);
					return;
				}
				range += botweapon->Range;
				archeryAmmoID = botweapon->ID;
			}
			else {
				archerbot->Say("I don't have a bow.");
				archerbot->CastToBot()->SetBotArcheryRange(0);
				return;
			}
			if(archerbot->CastToBot()->IsBotArcher()) {
				archerbot->CastToBot()->SetBotArcher(false);
				archerbot->Say("Using melee skills.");
				archerbot->CastToBot()->BotAddEquipItem(SLOT_PRIMARY, archerbot->CastToBot()->GetBotItemBySlot(SLOT_PRIMARY, &TempErrorMessage));

				if(!TempErrorMessage.empty()) {
					c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
					return;
				}
				//archerbot->SendWearChange(MATERIAL_PRIMARY);
				archerbot->CastToBot()->BotAddEquipItem(SLOT_SECONDARY, archerbot->CastToBot()->GetBotItemBySlot(SLOT_SECONDARY, &TempErrorMessage));

				if(!TempErrorMessage.empty()) {
					c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
					return;
				}
				//archerbot->SendWearChange(MATERIAL_SECONDARY);
				archerbot->CastToBot()->SetBotArcheryRange(0);
			}
			else {
				archerbot->CastToBot()->SetBotArcher(true);
				archerbot->Say("Using archery skills.");
				archerbot->CastToBot()->BotRemoveEquipItem(SLOT_PRIMARY);
				//archerbot->SendWearChange(MATERIAL_PRIMARY);
				archerbot->CastToBot()->BotRemoveEquipItem(SLOT_SECONDARY);
				//archerbot->SendWearChange(MATERIAL_SECONDARY);
				archerbot->CastToBot()->BotAddEquipItem(SLOT_SECONDARY, archeryBowID);
				archerbot->CastToBot()->SendBotArcheryWearChange(MATERIAL_SECONDARY, archeryMaterial, archeryColor);
				archerbot->CastToBot()->BotAddEquipItem(SLOT_PRIMARY, archeryAmmoID);
				archerbot->CastToBot()->SetBotArcheryRange(range);
			}
		}
		else {
			archerbot->Say("I don't know how to use a bow.");
		}
		return;
	}
Just scanning through, it looks like there may be a spot or 2 that could end up with a null pointer, but adding some debugging code would help to verify.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
 


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 01:41 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3