Postado Novembro 6, 2015 9 anos Boa noite!! Esse método faz a criatura ir andando até a posição passada no parametro. Testado em TFS 1.2 Reportem bugs. Adicione em: luascript.cpp: registerMethod("Creature", "moveTo", LuaScriptInterface::luaCreatureMoveTo); int32_t LuaScriptInterface::luaCreatureMoveTo(lua_State* L) { //creature:moveTo(pos) Creature* creature = getUserdata<Creature>(L, 1); if (!creature) { lua_pushnil(L); return 1; } const Position& position = getPosition(L, 2); FindPathParams fpp; fpp.minTargetDist = getNumber<int32_t>(L, 3, 0); fpp.maxTargetDist = getNumber<int32_t>(L, 4, 1); fpp.fullPathSearch = getBoolean(L, 5, fpp.fullPathSearch); fpp.clearSight = getBoolean(L, 6, fpp.clearSight); fpp.maxSearchDist = getNumber<int32_t>(L, 7, 150); std::forward_list<Direction> dirList; if (creature->getPathTo(position, dirList, fpp)) { creature->hasFollowPath = true; creature->startAutoWalk(dirList); pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } luascript.h: static int luaMoveCreatureTo(lua_State* L); Substitua a função original em: creature.cpp bool Creature::setFollowCreature(Creature* creature) { if (creature) { if (followCreature == creature) { return true; } const Position& creaturePos = creature->getPosition(); FindPathParams fpp; fpp.minTargetDist = 0; fpp.maxTargetDist = 1; fpp.fullPathSearch = true; fpp.clearSight = true; fpp.maxSearchDist = 150; std::forward_list<Direction> dirList; if (creaturePos.z != getPosition().z || !canSee(creaturePos) || !getPathTo(creaturePos, dirList, fpp)) { followCreature = nullptr; return false; } if (!listWalkDir.empty()) { listWalkDir.clear(); onWalkAborted(); } hasFollowPath = false; forceUpdateFollowPath = false; followCreature = creature; isUpdatingPath = true; } else { isUpdatingPath = false; followCreature = nullptr; } onFollowCreature(creature); return true; } monster.cpp bool Monster::getNextStep(Direction& dir, uint32_t& flags) { if (getHealth() <= 0) { //we dont have anyone watching might aswell stop walking eventWalk = 0; return false; } bool result = false; if (hasFollowPath) return Creature::getNextStep(dir, flags); else if ((!followCreature || !hasFollowPath) && !isSummon()) { if ((followCreature || getTimeSinceLastMove() > 1000) && !hasFollowPath && !isIdle) { //choose a random direction result = getRandomStep(getPosition(), dir); } } else if (isSummon() || followCreature) { result = Creature::getNextStep(dir, flags); if (result) { flags |= FLAG_PATHFINDING; } else { //target dancing if (attackedCreature && attackedCreature == followCreature) { if (isFleeing()) { result = getDanceStep(getPosition(), dir, false, false); } else if (mType->staticAttackChance < static_cast<uint32_t>(uniform_random(1, 100))) { result = getDanceStep(getPosition(), dir); } } } } if (result && (canPushItems() || canPushCreatures())) { const Position& pos = Spells::getCasterPosition(this, dir); Tile* tile = g_game.map.getTile(pos); if (tile) { if (canPushItems()) { Monster::pushItems(tile); } if (canPushCreatures()) { Monster::pushCreatures(tile); } } } return result; } Bom uso! Abraço! Editado Novembro 6, 2015 9 anos por MarceLoko (veja o histórico de edições)
Postado Novembro 6, 2015 9 anos Seu tópico foi aprovado e movido para a seção correta! Muito obrigado pela sua contribuição, nós do Tibia King agradecemos. Seu conteúdo com certeza ajudará à muitos outros, você recebeu +1 REP. Este tópico foi movido: Para: Programação Open Tibia > OTServ > Códigos Prontos _ .-'` `} _./) / } .'o \ | } '.___.'`.\ {` /`\_/ , `. } ME DA UMA NOZ! \=' .-' _`\ { `'`;/ `, } _\ @ ; } /__`;-...'--' Cluck!
Postado Maio 10, 2016 9 anos Pode ser para 0.4? http://Pokexmortal.com/ ONLINE! Todo mondo Bienvenido ! Serv serio 24/7 comunidade Latina!
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.