johnsamir
Advanced OT User
OK the first bug is that i can use mount or view outfit windows with gm, can't open it at all. this occurs only for gm normal players does not have this issue
the other bug is that npcs are not walking anymore
have added lots of comits and don't know when this begin, so where i must look in order to compare ? i use tfs 1.5/ 1.6 8.6
dont get errors in console
these are walking npc code
the other bug is that npcs are not walking anymore
have added lots of comits and don't know when this begin, so where i must look in order to compare ? i use tfs 1.5/ 1.6 8.6
dont get errors in console
these are walking npc code
LUA:
ool Npc::getNextStep(Direction& dir, uint32_t& flags)
{
if (Creature::getNextStep(dir, flags)) {
return true;
}
if (walkTicks == 0) {
return false;
}
if (focusCreature != 0) {
return false;
}
if (getTimeSinceLastMove() < walkTicks) {
return false;
}
return getRandomStep(dir);
}
void Npc::setIdle(const bool idle)
{
if (idle == isIdle) {
return;
}
if (isRemoved() || isDead()) {
return;
}
isIdle = idle;
if (isIdle) {
onIdleStatus();
}
}
bool Npc::canWalkTo(const Position& fromPos, Direction dir) const
{
if (masterRadius == 0) {
return false;
}
Position toPos = getNextPosition(dir, fromPos);
if (!Spawns::isInZone(masterPos, masterRadius, toPos)) {
return false;
}
Tile* tile = g_game.map.getTile(toPos);
if (!tile || tile->queryAdd(0, *this, 1, 0) != RETURNVALUE_NOERROR) {
return false;
}
if (!floorChange && (tile->hasFlag(TILESTATE_FLOORCHANGE) || tile->getTeleportItem())) {
return false;
}
if (!ignoreHeight && tile->hasHeight(1)) {
return false;
}
return true;
}
bool Npc::getRandomStep(Direction& dir) const
{
std::vector<Direction> dirList;
dirList.reserve(4);
const Position& creaturePos = getPosition();
if (canWalkTo(creaturePos, DIRECTION_NORTH)) {
dirList.push_back(DIRECTION_NORTH);
}
if (canWalkTo(creaturePos, DIRECTION_SOUTH)) {
dirList.push_back(DIRECTION_SOUTH);
}
if (canWalkTo(creaturePos, DIRECTION_EAST)) {
dirList.push_back(DIRECTION_EAST);
}
if (canWalkTo(creaturePos, DIRECTION_WEST)) {
dirList.push_back(DIRECTION_WEST);
}
if (dirList.empty()) {
return false;
}
dir = dirList[uniform_random(0, dirList.size() - 1)];
return true;
}
bool Npc::doMoveTo(const Position& pos, int32_t minTargetDist/* = 1*/, int32_t maxTargetDist/* = 1*/,
bool fullPathSearch/* = true*/, bool clearSight/* = true*/, int32_t maxSearchDist/* = 0*/)
{
listWalkDir.clear();
if (getPathTo(pos, listWalkDir, minTargetDist, maxTargetDist, fullPathSearch, clearSight, maxSearchDist)) {
startAutoWalk();
return true;
}
return false;
}
void Npc::turnToCreature(Creature* creature)
{
const Position& creaturePos = creature->getPosition();
const Position& myPos = getPosition();
const auto dx = Position::getOffsetX(myPos, creaturePos);
const auto dy = Position::getOffsetY(myPos, creaturePos);
float tan;
if (dx != 0) {
tan = static_cast<float>(dy) / dx;
} else {
tan = 10;
}
Direction dir;
if (std::abs(tan) < 1) {
if (dx > 0) {
dir = DIRECTION_WEST;
} else {
dir = DIRECTION_EAST;
}
} else {
if (dy > 0) {
dir = DIRECTION_NORTH;
} else {
dir = DIRECTION_SOUTH;
}
}
g_game.internalCreatureTurn(this, dir);
}
void Npc::setCreatureFocus(Creature* creature)
{
if (creature) {
focusCreature = creature->getID();
turnToCreature(creature);
} else {
focusCreature = 0;
}
}