1
This commit is contained in:
parent
2aca300cd2
commit
d3983b7347
@ -89,15 +89,18 @@ void Hero::Update(int delta_time)
|
||||
UpdatePoisoning();
|
||||
}
|
||||
if (GetMovement()->GetPathSize() > 0) {
|
||||
#ifdef DEBUG1
|
||||
glm::vec3 old_pos = GetPos().ToGlmVec3();
|
||||
#endif
|
||||
Global::Instance()->verify_set_pos = 1;
|
||||
UpdateMove();
|
||||
#ifdef DEBUG1
|
||||
a8::XPrintf("updatemove old_pos:%f,%f new_pos:%f,%f\n",
|
||||
{
|
||||
old_pos.x,
|
||||
old_pos.y,
|
||||
GetPos().x,
|
||||
GetPos().y,
|
||||
old_pos.z,
|
||||
GetPos().GetX(),
|
||||
GetPos().GetZ(),
|
||||
});
|
||||
#endif
|
||||
Global::Instance()->verify_set_pos = 0;
|
||||
@ -257,6 +260,9 @@ void Hero::DecHP(float dec_hp, int killer_id, const std::string killer_name, int
|
||||
if (dec_hp < 0.001f) {
|
||||
return;
|
||||
}
|
||||
if (HasBuffEffect(kBET_Invincible)) {
|
||||
return;
|
||||
}
|
||||
last_receive_dmg_frameno = room->GetFrameNo();
|
||||
float old_health = GetHP();
|
||||
float new_health = std::max(0.0f, GetHP() - dec_hp);
|
||||
|
@ -459,42 +459,72 @@ behaviac::EBTStatus HeroAgent::DoFlyToMasterAround()
|
||||
if (!GetOwner()->AsHero()->master.Get()) {
|
||||
return behaviac::BT_FAILURE;
|
||||
}
|
||||
glm::vec3 point;
|
||||
#if 1
|
||||
glm::vec3 move_dir = GlmHelper::UP;
|
||||
GlmHelper::RotateY(move_dir, a8::RandAngle());
|
||||
float move_distance = 30 + rand() % 20;
|
||||
|
||||
glm::vec3 start = GetOwner()->AsHero()->master.Get()->GetPos().ToGlmVec3();
|
||||
glm::vec3 end = start + move_dir * move_distance;
|
||||
GetOwner()->room->map_instance->Scale(start);
|
||||
GetOwner()->room->map_instance->Scale(end);
|
||||
|
||||
glm::vec3 hit_point = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
bool hit_result = false;
|
||||
bool ret = GetOwner()->room->map_instance->Raycast
|
||||
(
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result);
|
||||
if (ret) {
|
||||
GetOwner()->room->map_instance->UnScale(hit_point);
|
||||
point = hit_point;
|
||||
} else {
|
||||
point = GetOwner()->AsHero()->master.Get()->GetPos().ToGlmVec3();
|
||||
}
|
||||
#else
|
||||
glm::vec3 ref_point = GetOwner()->AsHero()->master.Get()->GetPos().ToGlmVec3();
|
||||
glm::vec3 point = GetOwner()->AsHero()->master.Get()->GetPos().ToGlmVec3();
|
||||
GetOwner()->room->map_instance->Scale(ref_point);
|
||||
if (GetOwner()->room->map_instance->FindRandomPointAroundCircle
|
||||
(
|
||||
ref_point,
|
||||
30 * GetOwner()->room->GetMapMeta()->scale(),
|
||||
0.21 * GetOwner()->room->GetMapMeta()->scale(),
|
||||
point
|
||||
)) {
|
||||
GetOwner()->room->map_instance->UnScale(point);
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("DoFlyToMasteraround1: %f,%f,%f %f,%f,%f\n",
|
||||
a8::XPrintf("DoFlyToMasteraround1: %f,%f,%f %f,%f,%f distance:%f\n",
|
||||
{point.x,
|
||||
point.y,
|
||||
point.z,
|
||||
GetOwner()->GetPos().GetX(),
|
||||
GetOwner()->GetPos().GetY(),
|
||||
GetOwner()->GetPos().GetZ(),
|
||||
GlmHelper::Norm(GetOwner()->GetPos().ToGlmVec3() - point)
|
||||
});
|
||||
#endif
|
||||
} else {
|
||||
point = GetOwner()->AsHero()->master.Get()->GetPos().ToGlmVec3();
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("DoFlyToMasteraround2: %f,%f,%f %f,%f,%f\n",
|
||||
a8::XPrintf("DoFlyToMasteraround2: %f,%f,%f %f,%f,%f distance:%f\n",
|
||||
{point.x,
|
||||
point.y,
|
||||
point.z,
|
||||
GetOwner()->GetPos().GetX(),
|
||||
GetOwner()->GetPos().GetY(),
|
||||
GetOwner()->GetPos().GetZ(),
|
||||
GlmHelper::Norm(GetOwner()->GetPos().ToGlmVec3() - point)
|
||||
});
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
Global::Instance()->verify_set_pos = 1;
|
||||
GetOwner()->GetMutablePos().FromGlmVec3(point);
|
||||
Global::Instance()->verify_set_pos = 0;
|
||||
GetOwner()->GetMovement()->ClearPath();
|
||||
GetOwner()->room->grid_service->MoveCreature(GetOwner());
|
||||
GetOwner()->SetAttackDir(GetOwner()->AsHero()->master.Get()->GetAttackDir());
|
||||
return behaviac::BT_SUCCESS;
|
||||
|
@ -295,7 +295,7 @@ bool MapInstance::FindRandomPointAroundCircle(const glm::vec3& center_pos,
|
||||
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
const float extents[3] = {2.f/10.0f, 4.f, 2.f/10.f};
|
||||
float nearestPt[3];
|
||||
|
||||
float center[3];
|
||||
@ -312,7 +312,8 @@ bool MapInstance::FindRandomPointAroundCircle(const glm::vec3& center_pos,
|
||||
float randomPt[3];
|
||||
dtStatus status = navmesh_query_->findRandomPointAroundCircle
|
||||
(startRef,
|
||||
center,
|
||||
//center,
|
||||
nearestPt,
|
||||
max_radius,
|
||||
&filter,
|
||||
frand,
|
||||
|
Loading…
x
Reference in New Issue
Block a user