添加血量同步

This commit is contained in:
aozhiwei 2019-04-12 11:48:21 +08:00
parent c7a15819a9
commit 4ffcc3c77f
5 changed files with 13 additions and 3 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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();

View File

@ -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
/*