1
This commit is contained in:
parent
676f69e15c
commit
4b9fb4a4d7
@ -651,7 +651,7 @@ void Bullet::ProcFlyHook(Entity* target)
|
|||||||
}
|
}
|
||||||
CreatureWeakPtr sender_bk = sender;
|
CreatureWeakPtr sender_bk = sender;
|
||||||
int ok_buff_id = gun_meta->_int_param1;
|
int ok_buff_id = gun_meta->_int_param1;
|
||||||
c->AutoNavigation(born_pos, gun_meta->bullet_speed() * 2,
|
c->AutoNavigation(born_pos.ToGlmVec3(), gun_meta->bullet_speed() * 2,
|
||||||
[buff_uniids, ok_buff_id, sender_bk] (Creature* c) mutable
|
[buff_uniids, ok_buff_id, sender_bk] (Creature* c) mutable
|
||||||
{
|
{
|
||||||
for (int buff_uniid : buff_uniids) {
|
for (int buff_uniid : buff_uniids) {
|
||||||
@ -663,7 +663,7 @@ void Bullet::ProcFlyHook(Entity* target)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
sender.Get()->AutoNavigation(GetPos(), gun_meta->bullet_speed() * 2,
|
sender.Get()->AutoNavigation(GetPos().ToGlmVec3(), gun_meta->bullet_speed() * 2,
|
||||||
[] (Creature* c)
|
[] (Creature* c)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -885,7 +885,7 @@ void Bullet::ProcNormalBullet(BulletCheckResult& result)
|
|||||||
if (!hited) {
|
if (!hited) {
|
||||||
if (raycast_hited) {
|
if (raycast_hited) {
|
||||||
if (result.flyed_distance > 0.001f) {
|
if (result.flyed_distance > 0.001f) {
|
||||||
sender.Get()->AutoNavigation(GetPos(), gun_meta->bullet_speed() * 2,
|
sender.Get()->AutoNavigation(raycast_hit_point_, gun_meta->bullet_speed() * 2,
|
||||||
[] (Creature* c)
|
[] (Creature* c)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -972,6 +972,7 @@ void Bullet::Raycast()
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
raycast_hited = true;
|
raycast_hited = true;
|
||||||
sender.Get()->room->map_instance->UnScale(hit_point);
|
sender.Get()->room->map_instance->UnScale(hit_point);
|
||||||
|
raycast_hit_point_ = hit_point;
|
||||||
raycast_len_ = GlmHelper::Norm(hit_point - born_pos.ToGlmVec3());
|
raycast_len_ = GlmHelper::Norm(hit_point - born_pos.ToGlmVec3());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ private:
|
|||||||
bool raycasted_ = false;
|
bool raycasted_ = false;
|
||||||
bool raycast_hited = false;
|
bool raycast_hited = false;
|
||||||
float raycast_len_ = 0.0f;
|
float raycast_len_ = 0.0f;
|
||||||
|
glm::vec3 raycast_hit_point_ = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
friend class EntityFactory;
|
friend class EntityFactory;
|
||||||
};
|
};
|
||||||
|
@ -2530,10 +2530,10 @@ void Creature::_UpdateSpecMove()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::AutoNavigation(Position target_pos, float speed,
|
void Creature::AutoNavigation(const glm::vec3& target_pos, float speed,
|
||||||
std::function<void (Creature*)> cb)
|
std::function<void (Creature*)> cb)
|
||||||
{
|
{
|
||||||
float distance = GetPos().Distance2D2(target_pos);
|
float distance = GetPos().DistanceGlmVec3(target_pos);
|
||||||
if (distance < 0.001f) {
|
if (distance < 0.001f) {
|
||||||
cb(this);
|
cb(this);
|
||||||
return;
|
return;
|
||||||
@ -2547,7 +2547,7 @@ void Creature::AutoNavigation(Position target_pos, float speed,
|
|||||||
{
|
{
|
||||||
CreatureWeakPtr c;
|
CreatureWeakPtr c;
|
||||||
Position src_pos;
|
Position src_pos;
|
||||||
Position target_pos;
|
glm::vec3 target_pos;
|
||||||
glm::vec3 dir;
|
glm::vec3 dir;
|
||||||
int exec_frameno = 0;
|
int exec_frameno = 0;
|
||||||
float speed = 0.0f;
|
float speed = 0.0f;
|
||||||
@ -2558,7 +2558,7 @@ void Creature::AutoNavigation(Position target_pos, float speed,
|
|||||||
context->c = GetWeakPtrRef();
|
context->c = GetWeakPtrRef();
|
||||||
context->src_pos = GetPos();
|
context->src_pos = GetPos();
|
||||||
context->target_pos = target_pos;
|
context->target_pos = target_pos;
|
||||||
context->dir = GetPos().CalcDir(target_pos);
|
context->dir = target_pos - GetPos().ToGlmVec3();
|
||||||
GlmHelper::Normalize(context->dir);
|
GlmHelper::Normalize(context->dir);
|
||||||
context->speed = speed;
|
context->speed = speed;
|
||||||
context->distance = distance;
|
context->distance = distance;
|
||||||
@ -2575,7 +2575,7 @@ void Creature::AutoNavigation(Position target_pos, float speed,
|
|||||||
Room* room = context->c.Get()->room;
|
Room* room = context->c.Get()->room;
|
||||||
Creature* c = context->c.Get();
|
Creature* c = context->c.Get();
|
||||||
|
|
||||||
glm::vec3 dir = c->GetPos().CalcDir(context->target_pos);
|
glm::vec3 dir = context->target_pos - c->GetPos().ToGlmVec3();
|
||||||
GlmHelper::Normalize(dir);
|
GlmHelper::Normalize(dir);
|
||||||
Position old_pos = c->GetPos();
|
Position old_pos = c->GetPos();
|
||||||
float move_length = context->speed / (float)SERVER_FRAME_RATE;
|
float move_length = context->speed / (float)SERVER_FRAME_RATE;
|
||||||
@ -2587,7 +2587,7 @@ void Creature::AutoNavigation(Position target_pos, float speed,
|
|||||||
Global::Instance()->verify_set_pos = 0;
|
Global::Instance()->verify_set_pos = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
a8::XPrintf("speed:%d src_pos:%f,%f,%f new_pos:%f,%f,%f move_distance:%f\n",
|
a8::XPrintf("speed:%d src_pos:%f,%f,%f new_pos:%f,%f,%f move_distance:%f src_distance:%f\n",
|
||||||
{
|
{
|
||||||
context->speed,
|
context->speed,
|
||||||
context->src_pos.x,
|
context->src_pos.x,
|
||||||
@ -2596,7 +2596,8 @@ void Creature::AutoNavigation(Position target_pos, float speed,
|
|||||||
new_pos.x,
|
new_pos.x,
|
||||||
new_pos.y,
|
new_pos.y,
|
||||||
new_pos.z,
|
new_pos.z,
|
||||||
move_distance
|
move_distance,
|
||||||
|
context->distance
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
bool ok = std::abs(move_distance - context->distance) < 0.0001f;
|
bool ok = std::abs(move_distance - context->distance) < 0.0001f;
|
||||||
|
@ -282,7 +282,7 @@ class Creature : public MoveableEntity
|
|||||||
float GetAttrAbs(int attr_id);
|
float GetAttrAbs(int attr_id);
|
||||||
float GetAttrRate(int attr_id);
|
float GetAttrRate(int attr_id);
|
||||||
void RecalcDtoAttr();
|
void RecalcDtoAttr();
|
||||||
void AutoNavigation(Position target_pos, float speed,
|
void AutoNavigation(const glm::vec3& target_pos, float speed,
|
||||||
std::function<void (Creature*)> cb);
|
std::function<void (Creature*)> cb);
|
||||||
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id);
|
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id);
|
||||||
void LockAttackDir(int time);
|
void LockAttackDir(int time);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user