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
angle = 2 * M_PI * rand_norm(); // A circle around the target.
x += cos(angle) * INTERACTION_DISTANCE * rand_norm();
y += sin(angle) * INTERACTION_DISTANCE * rand_norm();
bool exact = true;
float rnd = rand_norm();
x += cos(angle) * INTERACTION_DISTANCE * rnd;
y += sin(angle) * INTERACTION_DISTANCE * rnd;
// bool exact = true;
if (!unit->GetMap()->CheckCollisionAndGetValidCoords(unit, unit->GetPositionX(), unit->GetPositionY(),
unit->GetPositionZ(), x, y, z))
{
x = unit->GetPositionX();
y = unit->GetPositionY();
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;
}

View File

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