This commit is contained in:
aozhiwei 2021-04-29 14:40:32 +08:00
parent 81b1bdaa33
commit fef73d93f8
2 changed files with 33 additions and 15 deletions

View File

@ -25,6 +25,16 @@ void Car::Initialize()
if (!hero_meta_) { if (!hero_meta_) {
abort(); abort();
} }
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(hero_meta_->i->default_weapon());
if (weapon_meta) {
weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1;
weapons[GUN_SLOT1].weapon_id = weapon_meta->i->id();
weapons[GUN_SLOT1].weapon_lv = 1;
weapons[GUN_SLOT1].ammo = 10000;
weapons[GUN_SLOT1].meta = weapon_meta;
weapons[GUN_SLOT1].Recalc();
SetCurrWeapon(&weapons[GUN_SLOT1]);
}
} }
void Car::FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) void Car::FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data)
@ -44,6 +54,7 @@ void Car::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
TypeConvert::ToPb(GetPos(), p->mutable_pos()); TypeConvert::ToPb(GetPos(), p->mutable_pos());
TypeConvert::ToPb(GetMoveDir(), p->mutable_dir()); TypeConvert::ToPb(GetMoveDir(), p->mutable_dir());
p->set_car_id(meta->i->id()); p->set_car_id(meta->i->id());
p->set_heroid(meta->i->heroid());
p->set_driver(driver_ ? driver_->GetEntityUniId() : 0); p->set_driver(driver_ ? driver_->GetEntityUniId() : 0);
for (auto hum : passengers_) { for (auto hum : passengers_) {
auto less_data = p->add_passengers(); auto less_data = p->add_passengers();

View File

@ -192,22 +192,29 @@ void Player::UpdateShot()
Shot(); Shot();
return; return;
} }
Weapon* p_weapon = GetCurrWeapon(); if (GetCar() && GetCar()->IsDriver(this)) {
if (second_weapon.meta) { bool shot_ok = false;
p_weapon = &second_weapon; a8::Vec2 target_dir = attack_dir;
} GetCar()->Shot(target_dir, shot_ok, fly_distance);
if (shot_hold) { return;
++series_shot_frames; } else {
if (last_shot_frameno_ == 0 || Weapon* p_weapon = GetCurrWeapon();
( if (second_weapon.meta) {
(room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >= p_weapon = &second_weapon;
p_weapon->GetAttrValue(kHAT_FireRate)
) {
Shot();
} }
if (series_shot_frames > 8) { if (shot_hold) {
shot_hold = false; ++series_shot_frames;
series_shot_frames = 0; if (last_shot_frameno_ == 0 ||
(
(room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >=
p_weapon->GetAttrValue(kHAT_FireRate)
) {
Shot();
}
if (series_shot_frames > 8) {
shot_hold = false;
series_shot_frames = 0;
}
} }
} }
if (HasBuffEffect(kBET_Camouflage)) { if (HasBuffEffect(kBET_Camouflage)) {