完善载具逻辑

This commit is contained in:
aozhiwei 2021-03-04 14:19:39 +08:00
parent 97b641f3d3
commit 3ee93e59ca
5 changed files with 82 additions and 10 deletions

View File

@ -397,3 +397,6 @@ const int TERMINATOR_BUFF_ID = 1033;
const int TURN_OVER_SKILL_ID = 41001; const int TURN_OVER_SKILL_ID = 41001;
const int HUNLUAN_BUFFID = 6001; const int HUNLUAN_BUFFID = 6001;
const int DRIVER_BUFFID = 6003;
const int PASSENGER_BUFFID = 6004;

View File

@ -4330,10 +4330,21 @@ void Human::DoGetOnWithLoot(Loot* entity)
car_.car_id = item_meta->i->id(); car_.car_id = item_meta->i->id();
car_.meta = item_meta; car_.meta = item_meta;
SetPos(entity->GetPos()); SetPos(entity->GetPos());
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(car_.meta->i->buffid()); {
if (buff_meta) { MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(DRIVER_BUFFID);
AddBuff(this, buff_meta, 1); if (buff_meta) {
AddBuff(this, buff_meta, 1);
}
} }
{
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(car_.meta->i->buffid());
if (buff_meta) {
AddBuff(this, buff_meta, 1);
}
}
car_.driver = this;
car_.passengers.clear();
car_.passengers.insert(this);
CancelAction(); CancelAction();
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
room->TakeOnCarObject(car_.car_uniid); room->TakeOnCarObject(car_.car_uniid);
@ -4342,5 +4353,33 @@ void Human::DoGetOnWithLoot(Loot* entity)
void Human::DoGetOnWithTeammate(Human* teammate) void Human::DoGetOnWithTeammate(Human* teammate)
{ {
if (teammate->team_id != team_id) {
return;
}
if (teammate->GetEntityUniId() == GetEntityUniId()) {
return;
}
if (teammate->IsDead(room)) {
return;
}
if (!teammate->HasBuffEffect(kBET_Driver)) {
return;
}
if (HasBuffEffect(kBET_Driver)) {
return;
}
if (HasBuffEffect(kBET_Passenger)) {
return;
}
teammate->GetCar().passengers.insert(this);
SetPos(teammate->GetPos());
{
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(PASSENGER_BUFFID);
if (buff_meta) {
AddBuff(this, buff_meta, 1);
}
}
CancelAction();
SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }

View File

@ -883,7 +883,7 @@ void Room::FillSMUiUpdate(cs::SMUiUpdate& msg)
{ {
for (auto& pair : car_hash_) { for (auto& pair : car_hash_) {
if (!pair.second.taken) { if (!pair.second.taken) {
cs::MFCar* car = msg.add_car_list(); auto car = msg.add_car_list();
car->set_car_id(pair.second.car_id); car->set_car_id(pair.second.car_id);
TypeConvert::ToPb(pair.second.pos, car->mutable_pos()); TypeConvert::ToPb(pair.second.pos, car->mutable_pos());
} }

View File

@ -103,6 +103,8 @@ struct HumanCar
{ {
int car_id = 0; int car_id = 0;
int car_uniid = 0; int car_uniid = 0;
class Human* driver = nullptr;
std::set<class Human*> passengers;
MetaData::Equip* meta = nullptr; MetaData::Equip* meta = nullptr;
}; };

View File

@ -118,9 +118,11 @@ message MFVec2
property_type: 10 property_type: 10
property_subtype: property_subtype:
valule: valule:
property_type: 11 id
valule: car_uniid
property_type: 23 charid property_type: 23 charid
valule: charid valule: charid
*/ */
message MFPropertyChg message MFPropertyChg
{ {
optional int32 obj_id = 1; //id optional int32 obj_id = 1; //id
@ -213,6 +215,7 @@ message MFPlayerFull
optional int32 emoji2 = 26; //2 optional int32 emoji2 = 26; //2
optional int32 parachute = 27; // optional int32 parachute = 27; //
repeated MFBuff buff_list = 28; //buff列表 repeated MFBuff buff_list = 28; //buff列表
optional int32 car_uniid = 29; //id
optional bool can_revive = 30; // optional bool can_revive = 30; //
optional int32 revive_countdown = 31; // optional int32 revive_countdown = 31; //
@ -405,10 +408,33 @@ message MFSmokeFull
optional float rad = 3; // optional float rad = 3; //
} }
//-
message MFCarPart
{
optional int32 obj_uniid = 1; //id
optional MFVec2 pos = 2; //
optional MFVec2 dir = 3; //
}
//-
message MFCarFull
{
optional int32 obj_uniid = 1; //id
optional MFVec2 pos = 2; //
optional MFVec2 dir = 3; //
optional int32 car_id = 4; //id
optional int32 driver = 5; //id
/*
!!!
*/
repeated MFPlayerFull passengers = 6;
}
//- //-
message MFObjectPart message MFObjectPart
{ {
//1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke 10:hero //1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke 10:hero 11:car
optional int32 object_type = 1; optional int32 object_type = 1;
optional MFPlayerPart union_obj_1 = 2; optional MFPlayerPart union_obj_1 = 2;
@ -421,12 +447,13 @@ message MFObjectPart
optional MFProjectilePart union_obj_8 = 9; optional MFProjectilePart union_obj_8 = 9;
optional MFSmokePart union_obj_9 = 10; optional MFSmokePart union_obj_9 = 10;
optional MFHeroPart union_obj_10 = 11; optional MFHeroPart union_obj_10 = 11;
optional MFCarPart union_obj_11 = 12;
} }
//- //-
message MFObjectFull message MFObjectFull
{ {
//1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke 10:hero //1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke 10:hero 11:car
optional int32 object_type = 1; optional int32 object_type = 1;
optional MFPlayerFull union_obj_1 = 2; optional MFPlayerFull union_obj_1 = 2;
@ -439,6 +466,7 @@ message MFObjectFull
optional MFProjectileFull union_obj_8 = 9; optional MFProjectileFull union_obj_8 = 9;
optional MFSmokeFull union_obj_9 = 10; optional MFSmokeFull union_obj_9 = 10;
optional MFHeroFull union_obj_10 = 11; optional MFHeroFull union_obj_10 = 11;
optional MFCarFull union_obj_11 = 12;
optional int32 obj_uniid = 14; //id optional int32 obj_uniid = 14; //id
optional int32 object_flags = 15; // 1<<0: 1<<1 optional int32 object_flags = 15; // 1<<0: 1<<1
@ -686,8 +714,8 @@ message MFPlane
optional MFVec2 end_point = 2; // optional MFVec2 end_point = 2; //
} }
// //
message MFCar message MFMapCarInfo
{ {
optional int32 car_id = 1; //id(equip表) optional int32 car_id = 1; //id(equip表)
optional MFVec2 pos = 2; // optional MFVec2 pos = 2; //
@ -1051,7 +1079,7 @@ message SMUiUpdate
{ {
optional int32 alive_count = 1; // optional int32 alive_count = 1; //
optional int32 kill_count = 2; // optional int32 kill_count = 2; //
repeated MFCar car_list = 3; // repeated MFMapCarInfo car_list = 3; //
// //
optional int32 zombie_num = 10; // optional int32 zombie_num = 10; //