Jak wiadomo, selfFollow u NPC działa TYLKO, gdy docelowym obiektem do podążania jest gracz. Co to oznacza? Oznacza to tyle, że w obecnej sytuacji NPC nie może (oczywiście, jeśli taki skrypt napiszemy) podążać za potworami.
Akurat potrzebowałem czegoś takiego i postanowiłem się z tym podzielić:
npc.cpp
Znajdź:
Kod:
lua_register(m_luaState, "selfFollow", NpcScriptInterface::luaActionFollow);
Kod:
lua_register(m_luaState, "selfFollowCreature", NpcScriptInterface::luaActionFollowCreature);
Kod:
int32_t NpcScriptInterface::luaActionFollow(lua_State* L)
Kod:
int32_t NpcScriptInterface::luaActionFollowCreature(lua_State* L)
{
//selfFollowCreature(cid)
ScriptEnviroment* env = getScriptEnv();
Creature* creature = env->getCreatureByUID(popNumber(L));
Npc* npc = env->getNpc();
if(!creature)
{
lua_pushboolean(L, false);
return 1;
}
if(!npc)
{
lua_pushboolean(L, false);
return 1;
}
lua_pushboolean(L, npc->setFollowCreature(creature, true));
return 1;
}
Znajdź:
Kod:
static int32_t luaActionFollow(lua_State* L);
Kod:
static int32_t luaActionFollowCreature(lua_State* L);
Do powyższego używamy selfFollowCreature(cel) zamiast selfFollow(cel)
Testowałem na TFS 0.3 w wersji na 8.42.
(Poprzednio to napisałem, ale była jakaś cofka forum >.<)
Zakładki