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_) { if (later_removed_) {
return; return;
} }
if (!CanOn(passenger)) {
return;
}
if (meta->_int_param2 <= 0) { if (meta->_int_param2 <= 0) {
A8_ABORT(); A8_ABORT();
} }
@ -577,3 +580,14 @@ void Car::Update(int delta_time)
UpdateSkill(); 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 OnKillTarget(Creature* target);
void SetShotDir(const glm::vec3& dir) { curr_shot_dir_ = dir; }; void SetShotDir(const glm::vec3& dir) { curr_shot_dir_ = dir; };
bool IsSingle(); bool IsSingle();
bool CanOn(Human* hum);
void SetSpecialOperators(std::set<int>& special_operators);
private: private:
int AllocSeat(); int AllocSeat();
@ -67,6 +69,7 @@ class Car : public Creature
int cur_buff_idx_ = -1; int cur_buff_idx_ = -1;
float cur_oil_ = 0; float cur_oil_ = 0;
glm::vec3 curr_shot_dir_ = GlmHelper::ZERO; glm::vec3 curr_shot_dir_ = GlmHelper::ZERO;
std::set<int> special_operators_;
friend class PBUtils; friend class PBUtils;
}; };

View File

@ -318,7 +318,8 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
car_uniid, car_uniid,
equip_meta, equip_meta,
pos, pos,
0); 0,
nullptr);
if (c) { if (c) {
#if 0 #if 0
CarObject car; CarObject car;

View File

@ -2093,8 +2093,8 @@ void Human::DoGetOnWithLoot(Loot* entity)
entity->GetUniId(), entity->GetUniId(),
item_meta, item_meta,
entity->GetPos().ToGlmVec3(), entity->GetPos().ToGlmVec3(),
team_id team_id,
); nullptr);
car->GetOn(this); car->GetOn(this);
#ifdef DEBUG #ifdef DEBUG
a8::XPrintf("DoGetOnWithLoot uniid:%d car_uniid:%d\n", {car->GetUniId(), car->car_uniid}); 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, int car_uniid,
const mt::Equip* item_meta, const mt::Equip* item_meta,
const glm::vec3& pos, const glm::vec3& pos,
int team_id) int team_id,
std::set<int>* special_operators)
{ {
Car* car = EntityFactory::Instance()->MakeCar(AllocUniid()); Car* car = EntityFactory::Instance()->MakeCar(AllocUniid());
car->car_uniid = car_uniid; car->car_uniid = car_uniid;
@ -711,6 +712,9 @@ Car* Room::CreateCar(Human* driver,
car->team_id = team_id; car->team_id = team_id;
car->GetMutablePos().FromGlmVec3(pos); car->GetMutablePos().FromGlmVec3(pos);
car->SetAttackDir(GlmHelper::DONW); car->SetAttackDir(GlmHelper::DONW);
if (special_operators) {
car->SetSpecialOperators(*special_operators);
}
car->Initialize(); car->Initialize();
AddToEntityHash(car); AddToEntityHash(car);
AddToMoveableHash(car); AddToMoveableHash(car);
@ -3008,7 +3012,8 @@ void Room::CreateWorldObjects()
car_uniid, car_uniid,
equip_meta, equip_meta,
pos, pos,
0); 0,
nullptr);
if (c) { if (c) {
CarObject car; CarObject car;
car.car_id = equip_meta->id(); car.car_id = equip_meta->id();

View File

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

View File

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