Marcelo Druida
Intermediate OT User
how to set a monster to attack just a party or a guild?
bool Npc::loadFromXml(const std::string& filename)
{
xmlDocPtr doc = xmlParseFile(filename.c_str());
if(doc)
{
xmlNodePtr root, p;
root = xmlDocGetRootElement(doc);
if(xmlStrcmp(root->name,(const xmlChar*)"npc") != 0)
{
std::cerr << "Malformed XML" << std::endl;
return false;
}
int32_t intValue;
std::string strValue;
p = root->children;
std::string scriptfile = "";
if(readXMLString(root, "script", strValue))
scriptfile = strValue;
if(readXMLString(root, "name", strValue))
name = strValue;
else
name = "";
if(readXMLInteger(root, "speed", intValue))
baseSpeed = intValue;
else
baseSpeed = 110;
if(readXMLInteger(root, "attackable", intValue))
attackable = (intValue != 0);
if(readXMLInteger(root, "autowalk", intValue))
{
//Deprecated attribute.
std::cout << "[Notice - Npc::Npc] NPC Name: " << name << " - autowalk has been deprecated, use walkinterval." << std::endl;
walkTicks = 2000;
}
if(readXMLInteger(root, "walkinterval", intValue))
walkTicks = intValue;
if(readXMLInteger(root, "walkradius", intValue))
masterRadius = intValue;
if(readXMLInteger(root, "floorchange", intValue))
floorChange = (intValue != 0);
while(p)
{
if(xmlStrcmp(p->name, (const xmlChar*)"health") == 0)
{
if(readXMLInteger(p, "now", intValue))
health = intValue;
else
health = 100;
if(readXMLInteger(p, "max", intValue))
healthMax = intValue;
else
healthMax = 100;
}
else if(xmlStrcmp(p->name, (const xmlChar*)"look") == 0)
{
if(readXMLInteger(p, "type", intValue))
{
defaultOutfit.lookType = intValue;
if(readXMLInteger(p, "head", intValue))
defaultOutfit.lookHead = intValue;
if(readXMLInteger(p, "body", intValue))
defaultOutfit.lookBody = intValue;
if(readXMLInteger(p, "legs", intValue))
defaultOutfit.lookLegs = intValue;
if(readXMLInteger(p, "feet", intValue))
defaultOutfit.lookFeet = intValue;
if(readXMLInteger(p, "addons", intValue))
defaultOutfit.lookAddons = intValue;
}
else if(readXMLInteger(p, "typeex", intValue))
defaultOutfit.lookTypeEx = intValue;
if(readXMLInteger(p, "mount", intValue))
defaultOutfit.lookMount = intValue;
currentOutfit = defaultOutfit;
}
else if(xmlStrcmp(p->name, (const xmlChar*)"parameters") == 0)
{
for(xmlNodePtr q = p->children; q != NULL; q = q->next)
{
if(xmlStrcmp(q->name, (const xmlChar*)"parameter") == 0)
{
std::string paramKey;
std::string paramValue;
if(!readXMLString(q, "key", paramKey))
continue;
if(!readXMLString(q, "value", paramValue))
continue;
m_parameters[paramKey] = paramValue;
}
}
}
else if(xmlStrcmp(p->name, (const xmlChar*)"interaction") == 0)
{
if(readXMLInteger(p, "talkradius", intValue))
talkRadius = intValue;
if(readXMLInteger(p, "idletime", intValue) || readXMLInteger(p, "idletimeout", intValue))
idleTimeout = intValue;
if(readXMLInteger(p, "defaultpublic", intValue))
defaultPublic = intValue != 0;
responseList = loadInteraction(p->children);
}
p = p->next;
}
xmlFreeDoc(doc);
if(!scriptfile.empty())
{
m_npcEventHandler = new NpcScript(scriptfile, this);
if(!m_npcEventHandler->isLoaded())
return false;
}
return true;
}
return false;
}
It's not quite as simple as just making an NPC attackable. Doing things this way is going to force you to only be able to use certain weapons that you can't normally obtain throughout the server, then you'll have to make individual scripts for each one as well. There's actually a much simpler way to do it with monsters if you stop thinking everything has to be so complicated.hmmm...
<npc name="Buddel" script="default.lua" walkinterval="1500" floorchange="0" attackable="1">
THANK YOU VERY MUCH
Talk is cheap.. whats is the solution then huh?You're the one making it complicated. Onstatschange won't solve your problem, the monsters will still shoot at the targets. Lol