diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index db82746..b89bc88 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1862,6 +1862,7 @@ void Human::SendUIUpdate() cs::SMUiUpdate notifymsg; notifymsg.set_alive_count(room->AliveCount()); notifymsg.set_kill_count(stats.kills); + room->FillSMUiUpdate(notifymsg); SendNotifyMsg(notifymsg); } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 251dac5..d39a672 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -22,6 +22,7 @@ #include "app.h" #include "hero.h" #include "gamelog.h" +#include "typeconvert.h" const int ROOM_MAX_PLAYER_NUM = 50; @@ -344,14 +345,24 @@ void Room::CreateThings() } else { MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id); if (equip_meta) { - CreateLoot(equip_meta->i->id(), - a8::Vec2( - thing_tpl.i->x(), - thing_tpl.i->y() - ), - 1, - 1 - ); + int entity_uniid = CreateLoot(equip_meta->i->id(), + a8::Vec2( + thing_tpl.i->x(), + thing_tpl.i->y() + ), + 1, + 1 + ); + if (entity_uniid && equip_meta->i->is_luck() == 2) { + Entity* loot_entity = GetEntityByUniId(entity_uniid); + if (loot_entity && loot_entity->entity_type == ET_Loot) { + CarObject car; + car.car_uniid = loot_entity->entity_uniid; + car.car_id = equip_meta->i->id(); + car.pos = loot_entity->pos; + car_hash_[car.car_uniid] = car; + } + } } } } @@ -814,6 +825,17 @@ void Room::FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCo } } +void Room::FillSMUiUpdate(cs::SMUiUpdate& msg) +{ + for (auto& pair : car_hash_) { + if (!pair.second.taken) { + cs::MFCar* car = msg.add_car_list(); + car->set_car_id(pair.second.car_id); + TypeConvert::ToPb(pair.second.pos, car->mutable_pos()); + } + } +} + std::set* Room::GetAliveTeam() { for (auto& pair : team_hash_) { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index dfdf096..a521ac5 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -91,6 +91,7 @@ public: Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box); void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box, float& new_x, float& new_y); + void FillSMUiUpdate(cs::SMUiUpdate& msg); private: int AllocUniid(); @@ -135,5 +136,6 @@ private: std::map later_add_hash_; std::map human_hash_; + std::map car_hash_; std::map removed_robot_hash_; }; diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 795bb7d..bd52c4c 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -110,3 +110,11 @@ struct HumanAbility float def_add = 0.0f; float reflect_damage = 0.0f; }; + +struct CarObject +{ + int car_uniid = 0; + int car_id = 0; + a8::Vec2 pos; + bool taken = false; +}; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 05da9bd..aaa10c1 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -610,6 +610,13 @@ message MFPlane optional MFVector2D end_point = 2; //飞机终点 } +//载具 +message MFCar +{ + optional int32 car_id = 1; //载具id(读equip表) + optional MFVector2D pos = 2; //载具坐标 +} + //end mfmsg //加入 @@ -672,6 +679,7 @@ message CMMove optional int32 emote = 31; //表情id optional bool jump = 32; //跳伞 + optional bool get_down = 33; //下车 } //丢弃道具 @@ -835,4 +843,5 @@ message SMUiUpdate { optional int32 alive_count = 1; //存活数量 optional int32 kill_count = 2; //击杀数 -} + repeated MFCar car_list = 3; //载具列表 +} \ No newline at end of file