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