This commit is contained in:
aozhiwei 2020-07-29 11:52:32 +08:00
parent 6ac6bf7748
commit b463c11be1
5 changed files with 47 additions and 65 deletions

View File

@ -144,29 +144,6 @@ void FrameEvent::AddBulletNumChg(Human* hum)
hum->chged_bullet_nums_.push_back(idx); hum->chged_bullet_nums_.push_back(idx);
} }
#if 0
void FrameEvent::AddTankBulletNumChg(Human* hum)
{
chged_tank_bullet_nums_.push_back(hum);
int idx = chged_tank_bullet_nums_.size() - 1;
hum->chged_tank_bullet_nums_.push_back(idx);
}
void FrameEvent::AddTankOilValueChg(Human* hum)
{
chged_tank_oil_value_.push_back(hum);
int idx = chged_tank_oil_value_.size() - 1;
hum->chged_tank_oil_value_.push_back(idx);
}
void FrameEvent::AddTankOilMaxChg(Human* hum)
{
chged_tank_oil_max_.push_back(hum);
int idx = chged_tank_oil_max_.size() - 1;
hum->chged_tank_oil_max_.push_back(idx);
}
#endif
void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos) void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos)
{ {
{ {
@ -365,17 +342,6 @@ void FrameEvent::Clear()
if (!chged_bullet_nums_.empty()) { if (!chged_bullet_nums_.empty()) {
chged_bullet_nums_.clear(); chged_bullet_nums_.clear();
} }
#if 0
if (!chged_tank_bullet_nums_.empty()) {
chged_tank_bullet_nums_.clear();
}
if (!chged_tank_oil_value_.empty()) {
chged_tank_oil_value_.clear();
}
if (!chged_tank_oil_max_.empty()) {
chged_tank_oil_max_.clear();
}
#endif
if (!chged_buffs_.empty()) { if (!chged_buffs_.empty()) {
chged_buffs_.clear(); chged_buffs_.clear();
} }

View File

@ -17,11 +17,6 @@ public:
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos); void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
void AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, int effect); void AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, int effect);
void AddBulletNumChg(Human* hum); void AddBulletNumChg(Human* hum);
#if 0
void AddTankBulletNumChg(Human* hum);
void AddTankOilValueChg(Human* hum);
void AddTankOilMaxChg(Human* hum);
#endif
void AddHpChg(Human* hum); void AddHpChg(Human* hum);
void AddWeaponAmmoChg(Human* hum); void AddWeaponAmmoChg(Human* hum);
void AddBuff(Human* hum, Buff* buff); void AddBuff(Human* hum, Buff* buff);
@ -46,11 +41,6 @@ private:
std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_buffs_; std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_buffs_;
std::vector<std::tuple<Human*, int, int>> chged_items_; std::vector<std::tuple<Human*, int, int>> chged_items_;
std::vector<Human*> chged_bullet_nums_; std::vector<Human*> chged_bullet_nums_;
#if 0
std::vector<Human*> chged_tank_bullet_nums_;
std::vector<Human*> chged_tank_oil_value_;
std::vector<Human*> chged_tank_oil_max_;
#endif
std::vector<std::tuple<Human*, int, int>> chged_weapon_ammo_; std::vector<std::tuple<Human*, int, int>> chged_weapon_ammo_;
std::vector<Human*> chged_hps_; std::vector<Human*> chged_hps_;
std::vector<Human*> chged_skillcds_; std::vector<Human*> chged_skillcds_;

View File

@ -458,6 +458,24 @@ void Human::Shot(a8::Vec2& target_dir, bool& shot_ok)
shot_ok = true; shot_ok = true;
} }
void Human::CarShot(a8::Vec2& target_dir)
{
if (!car_weapon.meta) {
return;
}
InternalShot(this,
car_weapon.meta,
car_weapon.GetUpgradeMeta(),
car_weapon.bullet_meta,
car_weapon.weapon_lv,
0,
5,
false);
last_shot_frameno_ = room->GetFrameNo();
}
void Human::RecalcSelfCollider() void Human::RecalcSelfCollider()
{ {
if (!self_collider_) { if (!self_collider_) {
@ -470,7 +488,10 @@ void Human::RecalcSelfCollider()
Buff* buff = GetBuffByEffectId(kBET_Car); Buff* buff = GetBuffByEffectId(kBET_Car);
if (buff) { if (buff) {
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(buff->meta->param4); MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(buff->meta->param4);
if (equip_meta && equip_meta->i->rad() > 1) { if (equip_meta &&
equip_meta->i->rad() > 1 &&
equip_meta->i->equip_type() == EQUIP_TYPE_CAR
) {
self_collider_->rad = equip_meta->i->rad(); self_collider_->rad = equip_meta->i->rad();
} }
} }
@ -2092,17 +2113,6 @@ void Human::ClearFrameData()
if (!chged_bullet_nums_.empty()) { if (!chged_bullet_nums_.empty()) {
chged_bullet_nums_.clear(); chged_bullet_nums_.clear();
} }
#if 0
if (!chged_tank_bullet_nums_.empty()) {
chged_tank_bullet_nums_.clear();
}
if (!chged_tank_oil_value_.empty()){
chged_tank_oil_value_.clear();
}
if (!chged_tank_oil_max_.empty()){
chged_tank_oil_max_.clear();
}
#endif
if (!chged_hps_.empty()) { if (!chged_hps_.empty()) {
chged_hps_.clear(); chged_hps_.clear();
} }
@ -2866,6 +2876,21 @@ void Human::ProcBuffEffect(Human* caster, Buff* buff)
RecalcBuffAttr(); RecalcBuffAttr();
if (buff->meta->i->buff_effect() == kBET_Car) { if (buff->meta->i->buff_effect() == kBET_Car) {
RecalcSelfCollider(); RecalcSelfCollider();
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(buff->meta->param4);
if (equip_meta &&
equip_meta->i->equip_type() == EQUIP_TYPE_CAR &&
equip_meta->i->equip_subtype() == 1
) {
MetaData::Equip* car_weapon_meta = MetaMgr::Instance()->GetEquip(equip_meta->int_param1);
if (car_weapon_meta) {
car_weapon.weapon_idx = 100;
car_weapon.weapon_id = car_weapon_meta->i->id();
car_weapon.weapon_lv = 1;
car_weapon.ammo = 1;
car_weapon.meta = car_weapon_meta;
car_weapon.Recalc();
}
}
} }
} }
break; break;

View File

@ -99,6 +99,7 @@ class Human : public MoveableEntity
long long real_dead_frameno = 0; long long real_dead_frameno = 0;
Weapon default_weapon; Weapon default_weapon;
Weapon car_weapon;
std::vector<Weapon> weapons; std::vector<Weapon> weapons;
Weapon* curr_weapon = nullptr; Weapon* curr_weapon = nullptr;
@ -164,6 +165,7 @@ class Human : public MoveableEntity
long long GetRealDeadFrameNo(Room* room); long long GetRealDeadFrameNo(Room* room);
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over); void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
void Shot(a8::Vec2& target_dir, bool& shot_ok); void Shot(a8::Vec2& target_dir, bool& shot_ok);
void CarShot(a8::Vec2& target_dir);
void RecalcSelfCollider(); void RecalcSelfCollider();
bool IsCollisionInMapService(); bool IsCollisionInMapService();
void FindPathInMapService(); void FindPathInMapService();
@ -352,11 +354,6 @@ protected:
std::vector<int> chged_buffs_; std::vector<int> chged_buffs_;
std::set<Human*> observers_; std::set<Human*> observers_;
std::vector<int> chged_bullet_nums_; std::vector<int> chged_bullet_nums_;
#if 0
std::vector<int> chged_tank_bullet_nums_;
std::vector<int> chged_tank_oil_value_;
std::vector<int> chged_tank_oil_max_;
#endif
std::vector<int> chged_hps_; std::vector<int> chged_hps_;
std::vector<int> chged_skillcds_; std::vector<int> chged_skillcds_;
std::vector<int> chged_items_; std::vector<int> chged_items_;

View File

@ -169,6 +169,9 @@ void Player::UpdateShot()
return; return;
} }
Weapon* p_weapon = curr_weapon; Weapon* p_weapon = curr_weapon;
if (car_weapon.meta) {
p_weapon = &car_weapon;
}
if (shot_hold) { if (shot_hold) {
++series_shot_frames; ++series_shot_frames;
if (last_shot_frameno_ == 0 || if (last_shot_frameno_ == 0 ||
@ -319,6 +322,11 @@ void Player::UpdateUseSkill()
void Player::Shot() void Player::Shot()
{ {
if (car_weapon.meta) {
CarShot(attack_dir);
return;
}
if (!curr_weapon->meta) { if (!curr_weapon->meta) {
return; return;
} }
@ -406,11 +414,7 @@ void Player::Shot()
AutoLoadingBullet(); AutoLoadingBullet();
} }
last_shot_frameno_ = room->GetFrameNo(); last_shot_frameno_ = room->GetFrameNo();
#if 1
room->frame_event.AddWeaponAmmoChg(this); room->frame_event.AddWeaponAmmoChg(this);
#else
need_sync_active_player = true;
#endif
} }
void Player::ProcInteraction() void Player::ProcInteraction()