Explanation: You can make any creature stop changing directions, usually via CTRL+ARROW KEY.
My first C++ function, tested only with players and TFS 1.0
1. In game.cpp find:
and replace with:
2. in creature.h after:
add the following:
3. In creature.cpp after:
add the following:
4. In luascript.h after:
add the following:
5. In luascript.cpp after:
add the following:
after:
add the following:
Most things learned from this thread xd: Lua Function - [TFS 1.2] creature:setNoMove(bool) & creature:canMove()
My first C++ function, tested only with players and TFS 1.0
1. In game.cpp find:
C++:
bool Game::internalCreatureTurn(Creature* creature, Direction dir) {
if (creature->getDirection() == dir) {
return false;
}
and replace with:
C++:
bool Game::internalCreatureTurn(Creature* creature, Direction dir) {
if (creature->getDirection() == dir || creature->canChangeDir()) {
return false;
}
2. in creature.h after:
C++:
virtual bool isInGhostMode() const {
return false;
}
add the following:
C++:
bool directionChange;
bool canChangeDir() const {
return directionChange;
}
void canChangeDirection(bool directionChange) {
this->directionChange = directionChange;
}
3. In creature.cpp after:
C++:
hiddenHealth = false;
add the following:
C++:
directionChange = false;
4. In luascript.h after:
C++:
static int32_t luaCreatureSetNoMove(lua_State* L);
add the following:
C++:
static int32_t luaCreatureCanChangeDirection(lua_State* L);
5. In luascript.cpp after:
C++:
registerMethod("Creature", "getPathTo", LuaScriptInterface::luaCreatureGetPathTo);
add the following:
C++:
registerMethod("Creature", "canChangeDirection", LuaScriptInterface::luaCreatureCanChangeDirection);
after:
C++:
int32_t LuaScriptInterface::luaCreatureGetPathTo(lua_State* L)
{
[......]
}
add the following:
C++:
int32_t LuaScriptInterface::luaCreatureCanChangeDirection(lua_State* L)
{
// creature:canChangeDirection(bool)
Creature* creature = getUserdata<Creature>(L, 1);
if (!creature) {
lua_pushnil(L);
return 1;
}
bool directionChange = getBoolean(L, 2);
creature->canChangeDirection(directionChange);
pushBoolean(L, true);
return 1;
}
Most things learned from this thread xd: Lua Function - [TFS 1.2] creature:setNoMove(bool) & creature:canMove()