Improve near npc move

This commit is contained in:
Yunfan Li
2024-12-03 23:30:09 +08:00
parent 87e8c05b20
commit 618358aa13
2 changed files with 8 additions and 8 deletions

View File

@@ -348,19 +348,19 @@ bool NewRpgMoveNpcAction::Execute(Event event)
} }
else else
angle = 2 * M_PI * rand_norm(); // A circle around the target. angle = 2 * M_PI * rand_norm(); // A circle around the target.
float rnd = rand_norm();
x += cos(angle) * INTERACTION_DISTANCE * rand_norm(); x += cos(angle) * INTERACTION_DISTANCE * rnd;
y += sin(angle) * INTERACTION_DISTANCE * rand_norm(); y += sin(angle) * INTERACTION_DISTANCE * rnd;
bool exact = true; // bool exact = true;
if (!unit->GetMap()->CheckCollisionAndGetValidCoords(unit, unit->GetPositionX(), unit->GetPositionY(), if (!unit->GetMap()->CheckCollisionAndGetValidCoords(unit, unit->GetPositionX(), unit->GetPositionY(),
unit->GetPositionZ(), x, y, z)) unit->GetPositionZ(), x, y, z))
{ {
x = unit->GetPositionX(); x = unit->GetPositionX();
y = unit->GetPositionY(); y = unit->GetPositionY();
z = unit->GetPositionZ(); z = unit->GetPositionZ();
exact = false; // exact = false;
} }
return MoveTo(mapId, x, y, z, false, false, false, exact); return MoveTo(mapId, x, y, z, false, false, false, true);
} }
return true; return true;
} }

View File

@@ -68,14 +68,14 @@ struct NewRpgInfo
break; break;
case NewRpgStatus::NEAR_RANDOM: case NewRpgStatus::NEAR_RANDOM:
out << "NEAR_RANDOM"; out << "NEAR_RANDOM";
out << "\nlastNearNpc: " << lastNearRandom; out << "\nlastNearRandom: " << lastNearRandom;
break; break;
case NewRpgStatus::IDLE: case NewRpgStatus::IDLE:
out << "IDLE"; out << "IDLE";
break; break;
case NewRpgStatus::REST: case NewRpgStatus::REST:
out << "REST"; out << "REST";
out << "\nlastNearNpc: " << lastRest; out << "\nlastRest: " << lastRest;
break; break;
default: default:
out << "UNKNOWN"; out << "UNKNOWN";