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

Development::Bots Forum for bots.

Reply
 
Thread Tools Display Modes
  #1  
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
  #2  
Old 01-07-2010, 02:45 PM
WildcardX
Developer
 
Join Date: Apr 2003
Posts: 589
Default

There is definitely an issue here that crashes the zone when you tell your bot ranger to use archery. I have reproduced this crash and I'll have a fix committed for it later today.

Thank you for reporting it.
__________________
Read my developer notes at my blog.

Quote:
If it's not on IRC, it ain't l33t!
Reply With Quote
  #3  
Old 01-07-2010, 04:27 PM
WildcardX
Developer
 
Join Date: Apr 2003
Posts: 589
Default

I just committed a fix to address this issue. Download at least r1082 from the repo and give it a try.
__________________
Read my developer notes at my blog.

Quote:
If it's not on IRC, it ain't l33t!
Reply With Quote
  #4  
Old 01-07-2010, 04:36 PM
Lillu
Hill Giant
 
Join Date: Sep 2008
Posts: 204
Default

WildcardX, you are a hero. Thanks for all your hard work!
__________________
Reply With Quote
  #5  
Old 01-07-2010, 06:17 PM
WildcardX
Developer
 
Join Date: Apr 2003
Posts: 589
Default

I love your love.
__________________
Read my developer notes at my blog.

Quote:
If it's not on IRC, it ain't l33t!
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 08:47 PM.


 

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