1
This commit is contained in:
parent
b819435e53
commit
dafb449779
@ -305,22 +305,34 @@ void Bullet::MapServiceUpdate()
|
||||
return;
|
||||
}
|
||||
if (sender.Get()) {
|
||||
SetPos(GetPos() + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE);
|
||||
float distance = (GetPos() - born_pos).Norm();
|
||||
if (room->OverBorder(GetPos(), gun_meta->i->bullet_rad())) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
Check(distance);
|
||||
if (!later_removed_) {
|
||||
room->RemoveObjectLater(this);
|
||||
later_removed_ = true;
|
||||
float move_length = gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
||||
do {
|
||||
float step_len = move_length - MetaMgr::Instance()->bullet_planck_step_length;
|
||||
if (step_len <= 0.001f) {
|
||||
if (move_length > 0.1f) {
|
||||
step_len = move_length;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
room->grid_service->MoveBullet(this);
|
||||
Check(distance);
|
||||
}
|
||||
move_length -= step_len;
|
||||
SetPos(GetPos() + dir * step_len);
|
||||
float distance = (GetPos() - born_pos).Norm();
|
||||
if (room->OverBorder(GetPos(), gun_meta->i->bullet_rad())) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
Check(distance);
|
||||
if (!later_removed_) {
|
||||
room->RemoveObjectLater(this);
|
||||
later_removed_ = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
room->grid_service->MoveBullet(this);
|
||||
Check(distance);
|
||||
}
|
||||
} while(!later_removed_ && move_length >= 0.0001f);
|
||||
} else {
|
||||
room->RemoveObjectLater(this);
|
||||
later_removed_ = true;
|
||||
@ -356,41 +368,6 @@ void Bullet::Check(float distance)
|
||||
int c_hit_num = 0;
|
||||
int t_hit_num = 0;
|
||||
std::set<Entity*> objects;
|
||||
room->grid_service->TraverseCreatures
|
||||
(room->GetRoomIdx(),
|
||||
GetGridList(),
|
||||
[this, &objects, &c_hit_num] (Creature* c, bool& stop)
|
||||
{
|
||||
if (sender.Get()->IsProperTarget(c)) {
|
||||
if (gun_meta->i->ispenetrate() &&
|
||||
hit_objects_.find(c->GetUniId()) != hit_objects_.end()) {
|
||||
//穿人
|
||||
return;
|
||||
}
|
||||
if (c->HasBuffEffect(kBET_BulletThrough)) {
|
||||
return;
|
||||
}
|
||||
AabbCollider aabb_box;
|
||||
c->GetHitAabbBox(aabb_box);
|
||||
if (c != sender.Get() && !c->dead && TestCollision(room, &aabb_box)) {
|
||||
if (meta->i->_inventory_slot() == IS_C4) {
|
||||
if (!c->IsHuman()) {
|
||||
objects.insert(c);
|
||||
if (gun_meta->i->ispenetrate()) {
|
||||
++c_hit_num;
|
||||
hit_objects_.insert(c->GetUniId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
objects.insert(c);
|
||||
if (gun_meta->i->ispenetrate()) {
|
||||
++c_hit_num;
|
||||
hit_objects_.insert(c->GetUniId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
{
|
||||
std::set<ColliderComponent*> colliders;
|
||||
room->map_service->GetColliders(room, GetX(), GetY(), colliders);
|
||||
@ -418,6 +395,43 @@ void Bullet::Check(float distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t_hit_num <= 0) {
|
||||
room->grid_service->TraverseCreatures
|
||||
(room->GetRoomIdx(),
|
||||
GetGridList(),
|
||||
[this, &objects, &c_hit_num] (Creature* c, bool& stop)
|
||||
{
|
||||
if (sender.Get()->IsProperTarget(c)) {
|
||||
if (gun_meta->i->ispenetrate() &&
|
||||
hit_objects_.find(c->GetUniId()) != hit_objects_.end()) {
|
||||
//穿人
|
||||
return;
|
||||
}
|
||||
if (c->HasBuffEffect(kBET_BulletThrough)) {
|
||||
return;
|
||||
}
|
||||
AabbCollider aabb_box;
|
||||
c->GetHitAabbBox(aabb_box);
|
||||
if (c != sender.Get() && !c->dead && TestCollision(room, &aabb_box)) {
|
||||
if (meta->i->_inventory_slot() == IS_C4) {
|
||||
if (!c->IsHuman()) {
|
||||
objects.insert(c);
|
||||
if (gun_meta->i->ispenetrate()) {
|
||||
++c_hit_num;
|
||||
hit_objects_.insert(c->GetUniId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
objects.insert(c);
|
||||
if (gun_meta->i->ispenetrate()) {
|
||||
++c_hit_num;
|
||||
hit_objects_.insert(c->GetUniId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
float bullet_range = gun_meta->i->range();
|
||||
if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange) > 0) {
|
||||
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);
|
||||
|
@ -203,6 +203,7 @@ public:
|
||||
MetaMgr::Instance()->newbie_fill_interval = MetaMgr::Instance()->GetSysParamAsInt("newbie_fill_interval", 5000);
|
||||
MetaMgr::Instance()->other_fill_interval = MetaMgr::Instance()->GetSysParamAsInt("other_fill_interval", 2000);
|
||||
MetaMgr::Instance()->map_cell_width = MetaMgr::Instance()->GetSysParamAsInt("map_cell_width", 64 * 8);
|
||||
MetaMgr::Instance()->bullet_planck_step_length = std::max(15, MetaMgr::Instance()->GetSysParamAsInt("bullet_planck_step_length", 15));
|
||||
METAMGR_READ(zbmode_gas_inactive_time, 25);
|
||||
METAMGR_READ(zbmode_game_duration, 300);
|
||||
METAMGR_READ(zbmode_player_num, 15);
|
||||
|
@ -170,6 +170,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
float android_pursuit_range = 0;
|
||||
float android_patrol_range = 0;
|
||||
int map_cell_width = 64 * 8;
|
||||
int bullet_planck_step_length = 15;
|
||||
MetaData::Player* human_meta = nullptr;
|
||||
MetaData::Player* android_meta = nullptr;
|
||||
MetaData::Player* terminator_meta = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user