TESTED ON A FRESH TFS 1.1
Not sure what it would be compatible with.
Hello there! I just figured this out and thought i'd share it since I could not find it anywhere.
*Disclaimer - I am very new to this. This is my first ever source edit. If there could of been an easier way please feel free to share it with me. Enjoy!
Find in luascript.cpp
Place Below
Find in luascript.cpp
Place Below
Find in luascript.h
Place Below
Find in monster.cpp
REPLACE WITH
Find in monster.h
Place Below
Find in monsters.cpp
Place Below
Find
Place Below
Find in monsters.h
Place Below
Edit any monster's xml file that you want to only attack when you attack them. Make sure these two flags are in there.
Not sure what it would be compatible with.
Hello there! I just figured this out and thought i'd share it since I could not find it anywhere.
*Disclaimer - I am very new to this. This is my first ever source edit. If there could of been an easier way please feel free to share it with me. Enjoy!
Find in luascript.cpp
C++:
registerMethod("MonsterType", "isHostile", LuaScriptInterface::luaMonsterTypeIsHostile);
C++:
registerMethod("MonsterType", "isHostileOnAttack", LuaScriptInterface::luaMonsterTypeIsHostileOnAttack);
Find in luascript.cpp
C++:
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;
}
C++:
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;
}
Find in luascript.h
C++:
static int luaMonsterTypeIsHostile(lua_State* L);
C++:
static int luaMonsterTypeIsHostileOnAttack(lua_State* L);
Find in monster.cpp
C++:
if (isHostile() || isSummon()) {
if (setAttackedCreature(creature) && !isSummon()) {
g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));
}
}
return setFollowCreature(creature);
}
C++:
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);
}
Find in monster.h
C++:
bool isHostile() const {
return mType->isHostile;
}
C++:
bool isHostileOnAttack() const {
return mType->isHostileOnAttack;
}
Find in monsters.cpp
C++:
isHostile = true;
C++:
isHostileOnAttack = false;
Find
C++:
} else if (strcasecmp(attrName, "hostile") == 0) {
mType->isHostile = attr.as_bool();
C++:
} else if (strcasecmp(attrName, "hostileonattack") == 0) {
mType->isHostileOnAttack = attr.as_bool();
Find in monsters.h
C++:
bool isHostile;
C++:
bool isHostileOnAttack;
Edit any monster's xml file that you want to only attack when you attack them. Make sure these two flags are in there.
XML:
<flag hostile="1"/>
<flag hostileonattack="1"/>
Last edited by a moderator: