Hi, i'm trying to adapt this CODE to the new new version of TFS. The problem for me is that the new TFS uses PUGI XML, not LIBXML, and I don't know how to uses PUGI XML yet.
The code is created by MeNi.
The problem is here:
So, someone knows what do to adapt this code to PUGI-XML? Thank you.
The code is created by MeNi.
Code:
int32_t LuaScriptInterface::luaDoCreateCustomMonster(lua_State* L)
{
//doCreateCustomMonster(name, pos, outfit, health, spells, corpse, distance, experience )
// created By MeNi for otland.net //
uint64_t health, corpse, distance, experience;
Outfit_t outfit;
PositionEx pos;
MonsterType* pobranyTyp = NULL;
pobranyTyp = new MonsterType();
experience = popNumber(L);
distance = popNumber(L);
corpse = popNumber(L);
std::string spells = popString(L);
health = popNumber(L);
outfit = popOutfit(L);
popPosition(L, pos);
std::string name = popString(L);
Monster* monster;
pobranyTyp->spellAttackList.clear();
pobranyTyp->health = health;
pobranyTyp->healthMax = health;
pobranyTyp->outfit = outfit;
pobranyTyp->name = name;
pobranyTyp->nameDescription = name;
pobranyTyp->lookCorpse = corpse;
pobranyTyp->targetDistance = distance;
pobranyTyp->experience = experience;
pobranyTyp->isSummonable =
pobranyTyp->isIllusionable =
pobranyTyp->isConvinceable =
pobranyTyp->isWalkable =
pobranyTyp->pushable = false;
pobranyTyp->isAttackable =
pobranyTyp->isHostile =
pobranyTyp->canPushItems =
pobranyTyp->canPushCreatures = true;
pobranyTyp->defense = 50;
pobranyTyp->armor = 80;
pobranyTyp->baseSpeed = 200;
pobranyTyp->changeTargetSpeed =
pobranyTyp->changeTargetChance = 0;
xmlDocPtr doc = xmlParseMemory(spells.c_str(), spells.length());
xmlNodePtr root = xmlDocGetRootElement(doc);
xmlNodePtr tmpNode = root->children;
while (tmpNode)
{
if (!xmlStrcmp(tmpNode->name, (const xmlChar*)"attack"))
{
spellBlock_t sb;
if (g_monsters.deserializeSpell(tmpNode, sb, "doCreateCustomMonster"))
pobranyTyp->spellAttackList.push_back(sb);
}
tmpNode = tmpNode->next;
}
monster = Monster::createMonster(pobranyTyp);
if (!g_game.placeCreature(monster, pos, false, false))
{
delete monster;
lua_pushboolean(L, true);
return 1;
}
ScriptEnvironment* env = getScriptEnv();
lua_pushnumber(L, env->addThing((Thing*)monster));
return 1;
}
The problem is here:
Code:
xmlDocPtr doc = xmlParseMemory(spells.c_str(), spells.length());
xmlNodePtr root = xmlDocGetRootElement(doc);
xmlNodePtr tmpNode = root->children;
while (tmpNode)
{
if (!xmlStrcmp(tmpNode->name, (const xmlChar*)"attack"))
{
spellBlock_t sb;
if (g_monsters.deserializeSpell(tmpNode, sb, "doCreateCustomMonster"))
pobranyTyp->spellAttackList.push_back(sb);
}
tmpNode = tmpNode->next;
}
So, someone knows what do to adapt this code to PUGI-XML? Thank you.