Ir para conteúdo

Posts Recomendados

Esse sistema faz com que existam monstros que não atacam você, se você não atacar ou usar magias antes. Então vamos ao passo-a-passo.



Encontre em luascript.cpp:

registerMethod("MonsterType", "isHostile", LuaScriptInterface::luaMonsterTypeIsHostile); 

Coloque abaixo:

registerMethod("MonsterType", "isHostileOnAttack", LuaScriptInterface::luaMonsterTypeIsHostileOnAttack); 


Encontre em luascript.cpp:

 int LuaScriptInterface::luaMonsterTypeIsHostile(lua_State* L)

{

// monsterType:isHostile()

MonsterType* monsterType = getUserdata<MonsterType>(L, 1);

if (monsterType) {

pushBoolean(L, monsterType->isHostile);

} else {

lua_pushnil(L);

}

return 1;

}  

Coloque abaixo:

 int LuaScriptInterface::luaMonsterTypeIsHostileOnAttack(lua_State* L)

{

// monsterType:isHostileOnAttack()

MonsterType* monsterType = getUserdata<MonsterType>(L, 1);

if (monsterType) {

pushBoolean(L, monsterType->isHostileOnAttack);

} else {

lua_pushnil(L);

}

return 1;

} 


Encontre em luascript.h:

static int luaMonsterTypeIsHostile(lua_State* L);

Coloque abaixo:

static int luaMonsterTypeIsHostileOnAttack(lua_State* L); 


Encontre em monster.cpp:

if (isHostile() || isSummon()) {

if (setAttackedCreature(creature) && !isSummon()) {

g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));

}

}

return setFollowCreature(creature);

}  

Substitua por:

 if (isHostileOnAttack() && getHealth() >= getMaxHealth()) {

return false;

} else if (isHostile() || isSummon()) {

if (setAttackedCreature(creature) && !isSummon()) {

g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));

}

}

return setFollowCreature(creature);

} 


Encontre em monster.h:

bool isHostile() const {

return mType->isHostile;

} 

Coloque abaixo:

bool isHostileOnAttack() const {

return mType->isHostileOnAttack;

} 


Encontre em monsters.cpp:

isHostile = true; 

Coloque abaixo:

isHostileOnAttack = false; 


Encontre em monsters.cpp:

} else if (strcasecmp(attrName, "hostile") == 0) {

mType->isHostile = attr.as_bool(); 

Coloque abaixo:

 } else if (strcasecmp(attrName, "hostileonattack") == 0) {

mType->isHostileOnAttack = attr.as_bool(); 


Encontre em monsters.h:

bool isHostile; 

Coloque abaixo:

bool isHostileOnAttack; 


Pronto, agora é só editar as flags no xml do monster que você que ataque apenas quando for atacado:

<flag hostile="1"/>
<flag hostileonattack="1"/>

Todos os créditos são de fish04k.

Link para o comentário
https://xtibia.com/forum/topic/234424-monstros-passivos-para-tfs-11/
Compartilhar em outros sites

×
×
  • Criar Novo...