This commit is contained in:
aozhiwei 2021-05-24 16:03:28 +08:00
parent 267da32a90
commit 01c792509c
7 changed files with 63 additions and 7 deletions

View File

@ -220,9 +220,11 @@ void Buff::ProcDriver(Creature* caster)
hold_weapons_.push_back(hum->weapons[hum->GetCar()->GetCurrWeapon()->weapon_idx]);
hum->weapons[hum->GetCar()->GetCurrWeapon()->weapon_idx] = *hum->GetCar()->GetCurrWeapon();
hum->SetCurrWeapon(&hum->weapons[hum->GetCar()->GetCurrWeapon()->weapon_idx]);
if (hum->GetCar()->meta && !hum->GetCar()->meta->shoot_offsets.empty()) {
hum->shoot_offset = hum->GetCar()->meta->shoot_offsets[0];
hum->GetCar()->shoot_offset = hum->GetCar()->meta->shoot_offsets[0];
if (hum->GetCar()->meta &&
hum->GetSeat() < hum->GetCar()->meta->shoot_offsets.size() &&
std::get<0>(hum->GetCar()->meta->shoot_offsets[hum->GetSeat()])
) {
hum->shoot_offset = std::get<1>(hum->GetCar()->meta->shoot_offsets[hum->GetSeat()]);
}
}
}
@ -236,6 +238,33 @@ void Buff::ProcRemoveDriver(Creature* caster)
caster->shoot_offset = a8::Vec2();
}
void Buff::ProcPassenger(Creature* caster)
{
hold_curr_weapon_idx_ = caster->GetCurrWeapon()->weapon_idx;
if (caster->IsHuman()) {
Human* hum = (Human*)caster;
if (hum->GetCar() && hum->GetCar()->GetCurrWeapon()) {
hold_weapons_.push_back(hum->weapons[hum->GetCar()->GetCurrWeapon()->weapon_idx]);
hum->weapons[hum->GetCar()->GetCurrWeapon()->weapon_idx] = *hum->GetCar()->GetCurrWeapon();
hum->SetCurrWeapon(&hum->weapons[hum->GetCar()->GetCurrWeapon()->weapon_idx]);
if (hum->GetCar()->meta &&
hum->GetSeat() < hum->GetCar()->meta->shoot_offsets.size() &&
std::get<0>(hum->GetCar()->meta->shoot_offsets[hum->GetSeat()])
) {
hum->shoot_offset = std::get<1>(hum->GetCar()->meta->shoot_offsets[hum->GetSeat()]);
}
}
}
caster->need_sync_active_player = true;
caster->SyncAroundPlayers(__FILE__, __LINE__, __func__);
}
void Buff::ProcRemovePassenger(Creature* caster)
{
RecoverHoldWeapons(caster);
caster->shoot_offset = a8::Vec2();
}
void Buff::RecoverHoldWeapons(Creature* caster)
{
for (auto& weapon : hold_weapons_) {

View File

@ -42,6 +42,8 @@ class Buff
void ProcRemoveBecome(Creature* caster);
void ProcDriver(Creature* caster);
void ProcRemoveDriver(Creature* caster);
void ProcPassenger(Creature* caster);
void ProcRemovePassenger(Creature* caster);
void ProcSprint(Creature* caster);
private:

View File

@ -932,6 +932,11 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
buff->ProcDriver(caster);
}
break;
case kBET_Passenger:
{
buff->ProcPassenger(caster);
}
break;
default:
{
}

View File

@ -3263,6 +3263,11 @@ void Human::OnBuffRemove(Buff& buff)
buff.ProcRemoveDriver(this);
}
break;
case kBET_Passenger:
{
buff.ProcRemovePassenger(this);
}
break;
default:
break;
}

View File

@ -175,10 +175,22 @@ namespace MetaData
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
assert(strings2.size() == 2);
if (strings2.size() >= 2) {
shoot_offsets.push_back(a8::Vec2((float)a8::XValue(strings2[0]).GetDouble(),
(float)a8::XValue(strings2[1]).GetDouble()));
shoot_offsets.push_back(std::make_tuple
(1,
a8::Vec2(
(float)a8::XValue(strings2[0]).GetDouble(),
(float)a8::XValue(strings2[1]).GetDouble())
)
);
} else {
shoot_offsets.push_back(std::make_tuple
(0,
a8::Vec2(
0.0f,
0.0f
)
));
}
}
}

View File

@ -64,7 +64,7 @@ namespace MetaData
const metatable::Equip* i = nullptr;
std::vector<std::tuple<float, float, float>> bullet_born_offset;
std::vector<a8::Vec2> shoot_offsets;
std::vector<std::tuple<int, a8::Vec2>> shoot_offsets;
std::array<int, IS_END> volume = {};
int int_param1 = 0;
float float_param1 = 0;

View File

@ -193,11 +193,14 @@ void Player::UpdateShot()
if (GetCar() && GetCar()->IsDriver(this)) {
bool shot_ok = false;
a8::Vec2 target_dir = GetAttackDir();
a8::Vec2 old_car_shoot_offset = GetCar()->shoot_offset;
GetCar()->shoot_offset = shoot_offset;
GetCar()->SetAttackDir(GetAttackDir());
GetCar()->Shot(target_dir, shot_ok, fly_distance);
if (!moving) {
GetCar()->SetMoveDir(GetAttackDir());
}
GetCar()->shoot_offset = old_car_shoot_offset;
shot_start = false;
return;
} else {