添加血量同步
This commit is contained in:
parent
c7a15819a9
commit
4ffcc3c77f
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user