重构shot
This commit is contained in:
parent
721fa5ffd5
commit
ab1a404ede
@ -129,7 +129,7 @@ void AndroidAI::DoAttack()
|
|||||||
shot_dir.Normalize();
|
shot_dir.Normalize();
|
||||||
shot_dir.Rotate((rand() % 10) / 180.0f);
|
shot_dir.Rotate((rand() % 10) / 180.0f);
|
||||||
sender->attack_dir = shot_dir;
|
sender->attack_dir = shot_dir;
|
||||||
sender->Shot(shot_dir);
|
sender->Shot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ void Human::FillMFTeamData(cs::MFTeamData* team_data)
|
|||||||
team_data->set_downed(downed);
|
team_data->set_downed(downed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::Shot(a8::Vec2& target_dir)
|
void Human::Shot()
|
||||||
{
|
{
|
||||||
if (!curr_weapon->meta) {
|
if (!curr_weapon->meta) {
|
||||||
return;
|
return;
|
||||||
@ -203,9 +203,6 @@ void Human::Shot(a8::Vec2& target_dir)
|
|||||||
CancelAction();
|
CancelAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
float fly_distance = 5;
|
|
||||||
#endif
|
|
||||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
||||||
@ -232,7 +229,9 @@ void Human::Shot(a8::Vec2& target_dir)
|
|||||||
}
|
}
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
bullet_dir.Rotate(bullet_angle / 180.0f);
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, attack_dir, fly_distance);
|
room->frame_event.AddBullet(this, bullet_born_pos, attack_dir, fly_distance);
|
||||||
room->CreateBullet(this, curr_weapon, bullet_born_pos, attack_dir, fly_distance);
|
if (room->BattleStarted()) {
|
||||||
|
room->CreateBullet(this, curr_weapon, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--curr_weapon->ammo;
|
--curr_weapon->ammo;
|
||||||
if (curr_weapon->ammo <= 0) {
|
if (curr_weapon->ammo <= 0) {
|
||||||
|
@ -136,7 +136,7 @@ class Human : public Entity
|
|||||||
virtual void FillMFPlayerStats(cs::MFPlayerStats* stats);
|
virtual void FillMFPlayerStats(cs::MFPlayerStats* stats);
|
||||||
virtual void GetAabbBox(AabbCollider& aabb_box);
|
virtual void GetAabbBox(AabbCollider& aabb_box);
|
||||||
void FillMFTeamData(cs::MFTeamData* team_data);
|
void FillMFTeamData(cs::MFTeamData* team_data);
|
||||||
void Shot(a8::Vec2& target_dir);
|
void Shot();
|
||||||
void RecalcSelfCollider();
|
void RecalcSelfCollider();
|
||||||
bool IsCollision();
|
bool IsCollision();
|
||||||
bool IsCollisionInMapService();
|
bool IsCollisionInMapService();
|
||||||
|
@ -247,63 +247,6 @@ void Player::UpdateUseSkill()
|
|||||||
DoSkill();
|
DoSkill();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Shot()
|
|
||||||
{
|
|
||||||
if (!curr_weapon->meta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curr_weapon->ammo <= 0) {
|
|
||||||
AutoLoadingBullet();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action_type == AT_Reload) {
|
|
||||||
CancelAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
|
||||||
a8::Vec2 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) {
|
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
|
|
||||||
a8::Vec2 bullet_born_pos = pos + bullet_born_offset;
|
|
||||||
a8::Vec2 bullet_dir = attack_dir;
|
|
||||||
float bullet_angle = std::get<2>(tuple);
|
|
||||||
if (curr_weapon->meta->i->bullet_angle() >= 0.01f) {
|
|
||||||
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
|
|
||||||
if (curr_weapon->upgrade_meta) {
|
|
||||||
angle -= curr_weapon->upgrade_meta->GetAttrValue(curr_weapon->weapon_lv, EA_BulletAngle) * 1000;
|
|
||||||
}
|
|
||||||
if (angle > 0) {
|
|
||||||
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
|
|
||||||
if (room->BattleStarted()) {
|
|
||||||
room->CreateBullet(this, curr_weapon, bullet_born_pos, bullet_dir, fly_distance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
--curr_weapon->ammo;
|
|
||||||
if (curr_weapon->ammo <= 0) {
|
|
||||||
AutoLoadingBullet();
|
|
||||||
}
|
|
||||||
last_shot_frameno_ = room->frame_no;
|
|
||||||
need_sync_active_player = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::ProcInteraction()
|
void Player::ProcInteraction()
|
||||||
{
|
{
|
||||||
for (auto obj_id : interaction_objids) {
|
for (auto obj_id : interaction_objids) {
|
||||||
|
@ -69,7 +69,6 @@ class Player : public Human
|
|||||||
void UpdateSpectate();
|
void UpdateSpectate();
|
||||||
void UpdateEmote();
|
void UpdateEmote();
|
||||||
void UpdateUseSkill();
|
void UpdateUseSkill();
|
||||||
void Shot();
|
|
||||||
void ProcInteraction();
|
void ProcInteraction();
|
||||||
void ObstacleInteraction(Obstacle* entity);
|
void ObstacleInteraction(Obstacle* entity);
|
||||||
void LootInteraction(Loot* entity);
|
void LootInteraction(Loot* entity);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user