1
This commit is contained in:
parent
b0a2bbada0
commit
c0a628978b
@ -63,6 +63,7 @@ void Ability::Clear()
|
|||||||
{
|
{
|
||||||
buff_attr_abs_ = {};
|
buff_attr_abs_ = {};
|
||||||
buff_attr_rate_ = {};
|
buff_attr_rate_ = {};
|
||||||
|
buff_attr_flag_ = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
float* Ability::GetBuffAttrAbsPtr(int attr_id)
|
float* Ability::GetBuffAttrAbsPtr(int attr_id)
|
||||||
@ -70,6 +71,7 @@ float* Ability::GetBuffAttrAbsPtr(int attr_id)
|
|||||||
if (!IsValidHumanAttr(attr_id)) {
|
if (!IsValidHumanAttr(attr_id)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
buff_attr_flag_[attr_id] = 1;
|
||||||
return &buff_attr_abs_[attr_id];
|
return &buff_attr_abs_[attr_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,5 +80,22 @@ float* Ability::GetBuffAttrRatePtr(int attr_id)
|
|||||||
if (!IsValidHumanAttr(attr_id)) {
|
if (!IsValidHumanAttr(attr_id)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
buff_attr_flag_[attr_id] = 1;
|
||||||
return &buff_attr_rate_[attr_id];
|
return &buff_attr_rate_[attr_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ability::FillMFAttrAdditionList(Room* room, Human* hum,
|
||||||
|
::google::protobuf::RepeatedPtrField<::cs::MFAttrAddition>* pb_attr_list)
|
||||||
|
{
|
||||||
|
for (int attr_id = 0; attr_id < kHAT_End; ++attr_id) {
|
||||||
|
if (!(attr_id == 12 || attr_id == 33)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (buff_attr_flag_[attr_id]) {
|
||||||
|
auto pb_attr = pb_attr_list->Add();
|
||||||
|
pb_attr->set_attr_id(attr_id);
|
||||||
|
pb_attr->set_abs_val(buff_attr_abs_[attr_id]);
|
||||||
|
pb_attr->set_rate_val(buff_attr_rate_[attr_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
#include "weakptr.h"
|
#include "weakptr.h"
|
||||||
|
|
||||||
|
class Room;
|
||||||
|
class Human;
|
||||||
class Ability
|
class Ability
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -14,8 +17,11 @@ class Ability
|
|||||||
float GetBuffAttrRate(int attr_id);
|
float GetBuffAttrRate(int attr_id);
|
||||||
float* GetBuffAttrAbsPtr(int attr_id);
|
float* GetBuffAttrAbsPtr(int attr_id);
|
||||||
float* GetBuffAttrRatePtr(int attr_id);
|
float* GetBuffAttrRatePtr(int attr_id);
|
||||||
|
void FillMFAttrAdditionList(Room* room, Human* hum,
|
||||||
|
::google::protobuf::RepeatedPtrField<::cs::MFAttrAddition>* pb_attr_list);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||||
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
||||||
|
std::array<int, kHAT_End> buff_attr_flag_ = {};
|
||||||
};
|
};
|
||||||
|
@ -436,6 +436,9 @@ void Creature::RecalcBuffAttr()
|
|||||||
SetHP(GetMaxHP());
|
SetHP(GetMaxHP());
|
||||||
GetTrigger()->HpChg();
|
GetTrigger()->HpChg();
|
||||||
}
|
}
|
||||||
|
if (IsHuman()) {
|
||||||
|
need_sync_active_player = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::OnBuffRemove(Buff& buff)
|
void Creature::OnBuffRemove(Buff& buff)
|
||||||
|
@ -168,6 +168,7 @@ void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data
|
|||||||
p->set_shoot_offset_x(shoot_offset.x);
|
p->set_shoot_offset_x(shoot_offset.x);
|
||||||
p->set_shoot_offset_y(shoot_offset.y);
|
p->set_shoot_offset_y(shoot_offset.y);
|
||||||
GetCurrWeapon()->ToPB(p->mutable_weapon());
|
GetCurrWeapon()->ToPB(p->mutable_weapon());
|
||||||
|
GetAbility()->FillMFAttrAdditionList(room, this, p->mutable_attr_addition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
|
void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
|
||||||
@ -1282,6 +1283,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
|||||||
FillSkillList(player_data->mutable_skill_list());
|
FillSkillList(player_data->mutable_skill_list());
|
||||||
player_data->set_shoot_offset_x(shoot_offset.x);
|
player_data->set_shoot_offset_x(shoot_offset.x);
|
||||||
player_data->set_shoot_offset_y(shoot_offset.y);
|
player_data->set_shoot_offset_y(shoot_offset.y);
|
||||||
|
GetAbility()->FillMFAttrAdditionList(room, this, player_data->mutable_attr_addition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::FillMFGasData(cs::MFGasData* gas_data)
|
void Human::FillMFGasData(cs::MFGasData* gas_data)
|
||||||
|
@ -1213,6 +1213,11 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
|
|||||||
if (buff_meta) {
|
if (buff_meta) {
|
||||||
MustBeAddBuff(this, buff_id);
|
MustBeAddBuff(this, buff_id);
|
||||||
}
|
}
|
||||||
|
} else if (cmd == "getattr" && cmds.size() >= 2) {
|
||||||
|
int attr_id = a8::XValue(cmds[1]);
|
||||||
|
float abs_val = GetAbility()->GetAttrAbs(attr_id);
|
||||||
|
float rate_val = GetAbility()->GetAttrRate(attr_id);
|
||||||
|
SendDebugMsg(a8::Format("attr_id:%d abs_val:%f rate_val:%f", {attr_id, abs_val, rate_val}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user