修复子弹越界问题

This commit is contained in:
aozhiwei 2019-05-06 16:23:46 +08:00
parent 657ff53618
commit d08fc79ffa
2 changed files with 19 additions and 1 deletions

View File

@ -161,6 +161,14 @@ void Human::Shot(Vector2D& target_dir)
#if 1
float fly_distance = 5;
#endif
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
Vector2D bullet_born_pos = pos + bullet_born_offset;
if (room->OverBorder(bullet_born_pos, 0)) {
return;
}
}
room->frame_event.AddShot(this);
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));

View File

@ -438,11 +438,19 @@ void Player::Shot()
return;
}
room->frame_event.AddShot(this);
if (room->gas_data.gas_mode != GasInactive &&
!a8::HasBitFlag(status, HS_Fly) &&
!a8::HasBitFlag(status, HS_Jump)
) {
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
Vector2D bullet_born_pos = pos + bullet_born_offset;
if (room->OverBorder(bullet_born_pos, 0)) {
return;
}
}
room->frame_event.AddShot(this);
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
@ -456,6 +464,8 @@ void Player::Shot()
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, bullet_dir, fly_distance);
}
} else {
return;
}
if (curr_weapon->weapon_idx != 0) {
--curr_weapon->ammo;