Versão testada pelo Autor do post: TFS 0.4 rev 4395
Provavelmente pode ser usada em outras versões
Versão testada por mim: TFS 0.3.6 pl1
Nome do code: setCreatureName(cid, newName, newNameDescription)
Pra quem não sabe nameDescription é o nomezinho que aparecerá quando você der look.
Exemplo: You see a troll.
a parte do "troll" é a descrição do nome.
esse codigo ja exist aki no xtibia mas so copie e postei no xtibia
Vamos começar.
Bom, primeiramente queria dizer que este code não fui eu que fiz, e foi retirado da otland com autorização.
Primeiramente vá em monster.h
E procure por:
class Monster : public Creature
feito isso você verá isto:
class Monster : public Creature{ private: Monster(MonsterType* _mType); public:#ifdef __ENABLE_SERVER_DIAGNOSTIC__ static uint32_t monsterCount;#endif
Na parte de:
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
Você adicionara em cima:
std::string name, nameDescription;
Ficando assim:
class Monster : public Creature{ private: Monster(MonsterType* _mType); public:std::string name, nameDescription;#ifdef __ENABLE_SERVER_DIAGNOSTIC__ static uint32_t monsterCount;#endif
Agora você irá procurar por:
virtual const std::string& getName() const {return mType->name;}
e substituir por:
virtual const std::string& getName() const {return name;}
Depois procure por:
virtual const std::string& getNameDescription() const {return mType->nameDescription;}
substitua por:
virtual const std::string& getNameDescription() const {return nameDescription;}
novamente procure por:
virtual std::string getDescription(int32_t) const {return mType->nameDescription + ".";}
e substitua por:
virtual std::string getDescription(int32_t) const {return nameDescription + ".";}
Feito este você irá em monster.cpp
e procure por:
Monster::Monster(MonsterType* _mType):
provavelmente você verá:
Monster::Monster(MonsterType* _mType): Creature(){isIdle = true; isMasterInRange = false; teleportToMaster = false; mType = _mType; spawn = NULL; raid = NULL;defaultOutfit = mType->outfit; currentOutfit = mType->outfit;
e embaixo de raid = NULL; você adicionará:
name = mType->name;nameDescription = mType->nameDescription;
feito isso você ira em luascript.h
e procure por:
static int32_t luaDoPlayerSendCancel(lua_State* L);
logo abaixo você adicionará:
static int32_t luaSetCreatureName(lua_State* L);
feito isso vá em luascript.cpp
e procure por:
lua_register(m_luaState, "doPlayerSendCancel", LuaScriptInterface::luaDoPlayerSendCancel);
e adicione abaixo:
//setCreatureName(cid, name, description)lua_register(m_luaState, "setCreatureName", LuaInterface::luaSetCreatureName);
depois procure por:
int32_t LuaScriptInterface::luaDoSendDefaultCancel(lua_State* L)
e adicione acima:
int32_t LuaInterface::luaSetCreatureName(lua_State* L){ //setCreatureName(cid, newName, newDescription) std::string newDesc = popString(L); std::string newName = popString(L); ScriptEnviroment* env = getEnv(); Creature* creature; if(creature = env->getCreatureByUID(popNumber(L))){Monster* monster = (Monster*)creature;monster->name = newName;monster->nameDescription = newDesc; lua_pushboolean(L, true);} else{ errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1;}
Feito tudo o que foi pedido tecle Ctrl+F11 e bom proveito.
agora em Seu mapa Wolrd Procure por uma position bem distante do mapa e crie uma areá pequena assim
[/spoiler
e após isso você va em data spells e naruto e procure por bunshin e coloque essa spells
function onCastSpell(cid, var)
local cloth = getCreatureOutfit(cid)
local health = getCreatureHealth(cid)
local maxhealth = getCreatureMaxHealth(cid)
local MaximoSummon = 2
local summons = getCreatureSummons(cid)
if(table.maxn(summons) < MaximoSummon) then
local pos = getPlayerPosition(cid)
local bpos = {x=pos.x+2, y = pos.y, z = pos.z}
local farAwayPos = {x = 2061, y = 2056, z = 7} -- aki é a position onde o bunshin vai ir e vai voltar
local Bunshin = doCreateMonster("Bunshin", farAwayPos)
doConvinceCreature(cid, Bunshin)
setCreatureMaxHealth(Bunshin, maxhealth)
doCreatureAddHealth(Bunshin, health)
doSetCreatureOutfit(Bunshin, cloth, -1)
setCreatureName(Bunshin, "".. getCreatureName(cid) .."", "a ".. getCreatureName(cid) .."")
addEvent(doSendMagicEffect, 300, pos, 2)
addEvent(doTeleportThing, 300, Bunshin, pos)
return TRUE
end
end
pronto salve o mapa na position e o spells e renicie sue servidor e teste
Caso Algum Erro So Deixar Que Estarei Ajudando