Funciona para tfs 1.0 ?
- Fórum
- OTServ
- Recursos
- Linguagens de Programação
- Monstros Passivos para TFS 1.1
LO
Monstros Passivos para TFS 1.1
Por Lordbaxx, 02 de jun. de 2015 em Linguagens de Programação
passive
tfs 1.1
script
2
1.2k
Por Lordbaxx, 02 de jun. de 2015 em Linguagens de Programação
info
Grupo: Conde
Registrado: 01/07/13
Posts: 521
Reputação: +291
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:
Coloque abaixo:
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:
Coloque abaixo:
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:
Coloque abaixo:
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.