1
This commit is contained in:
parent
615411eea6
commit
dcdf4e539e
@ -163,3 +163,50 @@ void Creature::OnBuffRemove(const Buff& buff)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Creature::RemoveBuffByEffectId(int buff_effect_id)
|
||||
{
|
||||
Buff* buff = GetBuffByEffectId(buff_effect_id);
|
||||
if (buff) {
|
||||
RemoveBuffById(buff->meta->i->buff_id());
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::ClearBuffList()
|
||||
{
|
||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||
if (buff_effect_[itr->meta->i->buff_effect()] == &(*itr)) {
|
||||
buff_effect_[itr->meta->i->buff_effect()] = nullptr;
|
||||
}
|
||||
OnBuffRemove(*itr);
|
||||
}
|
||||
buff_list_.clear();
|
||||
buff_effect_ = {};
|
||||
buff_attr_abs_ = {};
|
||||
buff_attr_rate_ = {};
|
||||
RecalcBuffAttr();
|
||||
}
|
||||
|
||||
float Creature::GetBuffAttrAbs(int attr_type)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_type)) {
|
||||
return buff_attr_abs_[attr_type];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Creature::GetBuffAttrRate(int attr_type)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_type)) {
|
||||
return buff_attr_rate_[attr_type];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Creature::FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list)
|
||||
{
|
||||
for (auto& itr : buff_list_) {
|
||||
auto buff = pb_buff_list->Add();
|
||||
itr.FillMFBuff(buff);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "moveableentity.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "cs_proto.pb.h"
|
||||
|
||||
class Creature : public MoveableEntity
|
||||
{
|
||||
public:
|
||||
@ -22,13 +24,19 @@ class Creature : public MoveableEntity
|
||||
void RemoveBuffById(int buff_id);
|
||||
virtual void SendDebugMsg(const std::string& debug_msg);
|
||||
void RecalcBuffAttr();
|
||||
void RemoveBuffByEffectId(int buff_effect_id);
|
||||
void ClearBuffList();
|
||||
float GetBuffAttrAbs(int attr_id);
|
||||
float GetBuffAttrRate(int attr_id);
|
||||
void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list);
|
||||
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
||||
|
||||
private:
|
||||
|
||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
||||
virtual void OnBuffRemove(const Buff& buff);
|
||||
|
||||
protected:
|
||||
private:
|
||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
||||
std::array<Buff*, kBET_End> buff_effect_ = {};
|
||||
|
@ -179,7 +179,7 @@ float Human::GetSpeed()
|
||||
return std::max(1, meta->i->reload_speed());
|
||||
}
|
||||
float speed = meta->i->move_speed();
|
||||
speed = (speed + buff_attr_abs_[kHAT_Speed]) * (1 + buff_attr_rate_[kHAT_Speed]);
|
||||
speed = (speed + GetBuffAttrAbs(kHAT_Speed)) * (1 + GetBuffAttrRate(kHAT_Speed));
|
||||
return std::max(speed, 1.0f);
|
||||
}
|
||||
}
|
||||
@ -413,6 +413,15 @@ long long Human::GetDeadFrameNo(Room* room)
|
||||
return dead_frameno;
|
||||
}
|
||||
|
||||
void Human::FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list)
|
||||
{
|
||||
for (auto& pair : items_) {
|
||||
auto p = pb_item_list->Add();
|
||||
p->set_key(pair.first);
|
||||
p->set_value(pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
long long Human::GetRealDeadFrameNo(Room* room)
|
||||
{
|
||||
return real_dead_frameno;
|
||||
@ -1735,23 +1744,6 @@ void Human::FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState
|
||||
}
|
||||
}
|
||||
|
||||
void Human::FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list)
|
||||
{
|
||||
for (auto& itr : buff_list_) {
|
||||
auto buff = pb_buff_list->Add();
|
||||
itr.FillMFBuff(buff);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list)
|
||||
{
|
||||
for (auto& pair : items_) {
|
||||
auto p = pb_item_list->Add();
|
||||
p->set_key(pair.first);
|
||||
p->set_value(pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::SummonHero(int heroid)
|
||||
{
|
||||
MetaData::Player* hero_meta = MetaMgr::Instance()->GetPlayer(heroid);
|
||||
@ -3076,29 +3068,6 @@ void Human::TriggerBuff(std::set<Entity*>& target_list, BuffTriggerType_e trigge
|
||||
}
|
||||
}
|
||||
|
||||
void Human::RemoveBuffByEffectId(int buff_effect_id)
|
||||
{
|
||||
Buff* buff = GetBuffByEffectId(buff_effect_id);
|
||||
if (buff) {
|
||||
RemoveBuffById(buff->meta->i->buff_id());
|
||||
}
|
||||
}
|
||||
|
||||
void Human::ClearBuffList()
|
||||
{
|
||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||
if (buff_effect_[itr->meta->i->buff_effect()] == &(*itr)) {
|
||||
buff_effect_[itr->meta->i->buff_effect()] = nullptr;
|
||||
}
|
||||
OnBuffRemove(*itr);
|
||||
}
|
||||
buff_list_.clear();
|
||||
buff_effect_ = {};
|
||||
buff_attr_abs_ = {};
|
||||
buff_attr_rate_ = {};
|
||||
RecalcBuffAttr();
|
||||
}
|
||||
|
||||
void Human::AddBuffPostProc(Creature* caster, Buff* buff)
|
||||
{
|
||||
room->frame_event.AddBuff(this, buff);
|
||||
@ -3306,22 +3275,6 @@ void Human::DecItem(int item_id, int item_num)
|
||||
}
|
||||
}
|
||||
|
||||
float Human::GetBuffAttrAbs(int attr_type)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_type)) {
|
||||
return buff_attr_abs_[attr_type];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Human::GetBuffAttrRate(int attr_type)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_type)) {
|
||||
return buff_attr_rate_[attr_type];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Human::GetAttrAbs(int attr_id)
|
||||
{
|
||||
float attr_abs_val = GetBuffAttrAbs(attr_id);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "creature.h"
|
||||
#include "cs_proto.pb.h"
|
||||
#include "GGListener.h"
|
||||
|
||||
namespace MetaData
|
||||
@ -170,6 +169,7 @@ class Human : public Creature
|
||||
virtual void GetAabbBox(AabbCollider& aabb_box) override;
|
||||
virtual bool IsDead(Room* room) override;
|
||||
virtual long long GetDeadFrameNo(Room* room) override;
|
||||
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
||||
long long GetRealDeadFrameNo(Room* room);
|
||||
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
|
||||
void Shot(a8::Vec2& target_dir, bool& shot_ok);
|
||||
@ -224,8 +224,6 @@ class Human : public Creature
|
||||
int GetVolume(int slot_id);
|
||||
void RecoverHp(int inc_hp);
|
||||
void FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState>* states);
|
||||
void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list);
|
||||
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
||||
void SummonHero(int heroid);
|
||||
void AddObserver(Human* observer);
|
||||
void RemoveObserver(Human* observer);
|
||||
@ -259,9 +257,6 @@ class Human : public Creature
|
||||
float GetSkillAtkAdd(int skill_id);
|
||||
void TriggerOneObjectBuff(Entity* target, BuffTriggerType_e trigger_type);
|
||||
void TriggerBuff(std::set<Entity*>& target_list, BuffTriggerType_e trigger_type);
|
||||
void RemoveBuffByEffectId(int buff_effect_id);
|
||||
void ClearBuffList();
|
||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff) override;
|
||||
int GetLevel() {return level_;};
|
||||
int GetExp() {return exp_;};
|
||||
void OnAttack() {};
|
||||
@ -269,8 +264,6 @@ class Human : public Creature
|
||||
int GetItemNum(int item_id);
|
||||
void AddItem(int item_id, int item_num);
|
||||
void DecItem(int item_id, int item_num);
|
||||
float GetBuffAttrAbs(int attr_id);
|
||||
float GetBuffAttrRate(int attr_id);
|
||||
float GetAttrAbs(int attr_id);
|
||||
float GetAttrRate(int attr_id);
|
||||
bool IsPlayer() const;
|
||||
@ -341,6 +334,7 @@ private:
|
||||
void NextReload(int prev_weapon_id, int prev_weapon_idx);
|
||||
void DoGetOnWithLoot(Loot* loot_entity);
|
||||
void DoGetOnWithCar(Car* car);
|
||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff) override;
|
||||
virtual void OnBuffRemove(const Buff& buff) override;
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user