This commit is contained in:
aozhiwei 2023-06-16 11:17:28 +08:00
parent feaddff103
commit cf1a03f5c8
7 changed files with 38 additions and 13 deletions

View File

@ -139,6 +139,9 @@ void Car::GetOn(Human* passenger)
if (later_removed_) {
return;
}
if (!CanOn(passenger)) {
return;
}
if (meta->_int_param2 <= 0) {
A8_ABORT();
}
@ -577,3 +580,14 @@ void Car::Update(int delta_time)
UpdateSkill();
}
}
bool Car::CanOn(Human* hum)
{
return special_operators_.empty() ||
special_operators_.find(hum->GetUniId()) != special_operators_.end();
}
void Car::SetSpecialOperators(std::set<int>& special_operators)
{
special_operators_ = special_operators;
}

View File

@ -49,6 +49,8 @@ class Car : public Creature
void OnKillTarget(Creature* target);
void SetShotDir(const glm::vec3& dir) { curr_shot_dir_ = dir; };
bool IsSingle();
bool CanOn(Human* hum);
void SetSpecialOperators(std::set<int>& special_operators);
private:
int AllocSeat();
@ -67,6 +69,7 @@ class Car : public Creature
int cur_buff_idx_ = -1;
float cur_oil_ = 0;
glm::vec3 curr_shot_dir_ = GlmHelper::ZERO;
std::set<int> special_operators_;
friend class PBUtils;
};

View File

@ -315,10 +315,11 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
int car_uniid = room->AllocUniid();
glm::vec3 pos = GetPos().ToGlmVec3();
Car* c = room->CreateCar(nullptr,
car_uniid,
equip_meta,
pos,
0);
car_uniid,
equip_meta,
pos,
0,
nullptr);
if (c) {
#if 0
CarObject car;

View File

@ -2089,12 +2089,12 @@ void Human::DoGetOnWithLoot(Loot* entity)
GetCar()->GetDown(this);
}
Car* car = room->CreateCar(
this,
entity->GetUniId(),
item_meta,
entity->GetPos().ToGlmVec3(),
team_id
);
this,
entity->GetUniId(),
item_meta,
entity->GetPos().ToGlmVec3(),
team_id,
nullptr);
car->GetOn(this);
#ifdef DEBUG
a8::XPrintf("DoGetOnWithLoot uniid:%d car_uniid:%d\n", {car->GetUniId(), car->car_uniid});

View File

@ -702,7 +702,8 @@ Car* Room::CreateCar(Human* driver,
int car_uniid,
const mt::Equip* item_meta,
const glm::vec3& pos,
int team_id)
int team_id,
std::set<int>* special_operators)
{
Car* car = EntityFactory::Instance()->MakeCar(AllocUniid());
car->car_uniid = car_uniid;
@ -711,6 +712,9 @@ Car* Room::CreateCar(Human* driver,
car->team_id = team_id;
car->GetMutablePos().FromGlmVec3(pos);
car->SetAttackDir(GlmHelper::DONW);
if (special_operators) {
car->SetSpecialOperators(*special_operators);
}
car->Initialize();
AddToEntityHash(car);
AddToMoveableHash(car);
@ -3008,7 +3012,8 @@ void Room::CreateWorldObjects()
car_uniid,
equip_meta,
pos,
0);
0,
nullptr);
if (c) {
CarObject car;
car.car_id = equip_meta->id();

View File

@ -172,7 +172,8 @@ public:
int car_uniid,
const mt::Equip* meta,
const glm::vec3& pos,
int team_id);
int team_id,
std::set<int>* special_operators);
Hero* CreateHero(Creature* master,
const mt::Hero* meta,
const glm::vec3& pos,

View File

@ -510,6 +510,7 @@ message MFCarFull
repeated MFEffect effect_list = 18; //
optional int32 team_id = 19; //id
repeated MFSkill skill_list = 20; //
repeated int32 special_operators = 21; //uniid,
/*
!!!