From 4ffcc3c77f6b62312a4874a5205b1545f05a5e90 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 12 Apr 2019 11:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=80=E9=87=8F=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 6 ++++++ server/gameserver/human.h | 1 + server/gameserver/player.cc | 3 ++- server/gameserver/playermgr.cc | 2 +- server/tools/protobuild/cs_proto.proto | 4 +++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 972d42a..71fa24c 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -68,6 +68,7 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data) attack_dir.ToPB(p->mutable_dir()); p->set_health(health); + p->set_max_health(GetMaxHP()); p->set_dead(dead); p->set_downed(downed); p->set_disconnected(disconnected); @@ -328,6 +329,11 @@ float Human::GetRadius() return meta->i->radius(); } +float Human::GetMaxHP() +{ + return meta->i->health(); +} + void Human::UpdatePoisoning() { if (dead) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index e7ae6e8..e9bd173 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -79,6 +79,7 @@ class Human : public Entity ColliderComponent* GetFirstCollision(); void FindPath(); float GetRadius(); + float GetMaxHP(); void UpdatePoisoning(); void SyncAroundPlayers(); void AutoLoadingBullet(bool manual = false); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index d4867c8..61f9bf3 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -193,7 +193,7 @@ void Player::UpdateAction() if (inventory[item_meta->i->_inventory_slot()] > 0) { float old_health = health; health += item_meta->i->heal(); - health = std::min(100.0f, health); + health = std::min(100.0f, GetMaxHP()); stats.heal_amount += health - old_health; --inventory[item_meta->i->_inventory_slot()]; need_sync_active_player = true; @@ -800,6 +800,7 @@ void Player::FillMFActivePlayerData(cs::MFActivePlayerData* player_data) player_data->set_helmet(helmet); player_data->set_chest(chest); player_data->set_health(health); + player_data->set_max_health(GetMaxHP()); player_data->set_cur_weapon_idx(curr_weapon->weapon_idx); player_data->set_cur_scope(curr_scope_idx); for (auto& weapon : weapons) { diff --git a/server/gameserver/playermgr.cc b/server/gameserver/playermgr.cc index 51ca00a..cec63da 100644 --- a/server/gameserver/playermgr.cc +++ b/server/gameserver/playermgr.cc @@ -24,7 +24,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(int socket, const cs::CMJoin& msg) hum->socket_handle = socket; hum->account_id = msg.account_id(); hum->name = msg.name(); - hum->health = 100; + hum->health = 0; hum->team_uniid = msg.team_uuid(); hum->team_mode = msg.team_mode(); hum->player_count = msg.player_count(); diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index a4ac42e..80bd12f 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -140,6 +140,7 @@ message MFPlayerFull optional MFVector2D pos = 2; //位置 optional MFVector2D dir = 3; //朝向 + optional float max_health = 5; //血量 optional float health = 6; //血量 optional bool dead = 7; //是否已死亡 optional bool downed = 8; //是否跌倒 @@ -354,7 +355,8 @@ message MFActivePlayerData optional int32 helmet = 32; //头盔 optional int32 chest = 33; //防弹衣 - optional float health = 34; //血量 + optional float max_health = 34; //血量 + optional float health = 35; //血量 optional int32 cur_scope = 10; //当前视野倍数 1 2 4 8 15 /*