1
This commit is contained in:
parent
faa5d82a2a
commit
b7592f1601
@ -19,6 +19,7 @@
|
||||
#include "skillhelper.h"
|
||||
#include "trigger.h"
|
||||
#include "ability.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Equip.h"
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "trigger.h"
|
||||
#include "ability.h"
|
||||
#include "battledatacontext.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "mt/Hero.h"
|
||||
#include "mt/Equip.h"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "trigger.h"
|
||||
#include "ability.h"
|
||||
#include "battledatacontext.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Hero.h"
|
||||
@ -93,9 +94,9 @@ Buff* Creature::GetBuffByEffectId(int effect_id)
|
||||
|
||||
Buff* Creature::GetBuffById(int buff_id)
|
||||
{
|
||||
for (Buff& buff : buff_list_) {
|
||||
if (buff.meta->buff_id() == buff_id) {
|
||||
return &buff;
|
||||
for (auto buff : buff_list_) {
|
||||
if (buff->meta->buff_id() == buff_id) {
|
||||
return buff.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@ -103,9 +104,9 @@ Buff* Creature::GetBuffById(int buff_id)
|
||||
|
||||
Buff* Creature::GetBuffByUniId(int buff_uniid)
|
||||
{
|
||||
for (Buff& buff : buff_list_) {
|
||||
if (buff.buff_uniid == buff_uniid) {
|
||||
return &buff;
|
||||
for (auto buff : buff_list_) {
|
||||
if (buff->buff_uniid == buff_uniid) {
|
||||
return buff.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@ -114,8 +115,8 @@ Buff* Creature::GetBuffByUniId(int buff_uniid)
|
||||
int Creature::GetBuffNum(int buff_id)
|
||||
{
|
||||
int num = 0;
|
||||
for (Buff& buff : buff_list_) {
|
||||
if (buff.meta->buff_id() == buff_id) {
|
||||
for (auto buff : buff_list_) {
|
||||
if (buff->meta->buff_id() == buff_id) {
|
||||
++num;
|
||||
}
|
||||
}
|
||||
@ -185,7 +186,8 @@ int Creature::AddBuff(Creature* caster,
|
||||
}
|
||||
++buff_uniid_;
|
||||
int new_buff_uniid = buff_uniid_;
|
||||
Buff* buff = &a8::FastAppend(buff_list_);
|
||||
auto buff = std::make_shared<Buff>();
|
||||
buff_list_.push_back(buff);
|
||||
buff->buff_uniid = new_buff_uniid;
|
||||
buff->SetCaster(caster);
|
||||
buff->owner = this;
|
||||
@ -196,7 +198,7 @@ int Creature::AddBuff(Creature* caster,
|
||||
buff->Init();
|
||||
buff->PreProcess();
|
||||
if (on_add_buff) {
|
||||
on_add_buff(buff);
|
||||
on_add_buff(buff.get());
|
||||
}
|
||||
if (buff->meta->lock_move()) {
|
||||
IncDisableMoveTimes();
|
||||
@ -235,7 +237,7 @@ int Creature::AddBuff(Creature* caster,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ProcBuffEffect(caster, buff);
|
||||
ProcBuffEffect(caster, buff.get());
|
||||
#ifdef DEBUG
|
||||
if (!f8::IsTestEnv()) {
|
||||
if (!GetBuffByUniId(new_buff_uniid)) {
|
||||
@ -243,7 +245,7 @@ int Creature::AddBuff(Creature* caster,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
AddBuffPostProc(caster, buff);
|
||||
AddBuffPostProc(caster, buff.get());
|
||||
#ifdef DEBUG
|
||||
if (!f8::IsTestEnv()) {
|
||||
if (!GetBuffByUniId(new_buff_uniid)) {
|
||||
@ -252,7 +254,7 @@ int Creature::AddBuff(Creature* caster,
|
||||
}
|
||||
#endif
|
||||
if (!buff->meta->only_server()) {
|
||||
room->frame_event.AddBuff(GetWeakPtrRef(), buff);
|
||||
room->frame_event.AddBuff(GetWeakPtrRef(), buff.get());
|
||||
}
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -284,8 +286,8 @@ int Creature::AddBuff(Creature* caster,
|
||||
|
||||
bool Creature::IsImmuneBuffEffect(int buff_effect)
|
||||
{
|
||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||
if (itr->meta->IsImmuneBuffEffect(buff_effect)) {
|
||||
for (auto buff : buff_list_) {
|
||||
if (buff->meta->IsImmuneBuffEffect(buff_effect)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -385,10 +387,9 @@ int Creature::TryAddBuffWithTarget(Creature* caster, int buff_id)
|
||||
void Creature::RemoveBuffById(int buff_id)
|
||||
{
|
||||
int buff_uniid = 0;
|
||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||
Buff& buff = *itr;
|
||||
if (buff.meta->buff_id() == buff_id) {
|
||||
buff_uniid = buff.buff_uniid;
|
||||
for (auto buff : buff_list_) {
|
||||
if (buff->meta->buff_id() == buff_id) {
|
||||
buff_uniid = buff->buff_uniid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -402,12 +403,12 @@ void Creature::RemoveBuffByUniId(int buff_uniid)
|
||||
int buff_id = 0;
|
||||
std::vector<std::tuple<const mt::Buff*, Creature*>> removed_buffs;
|
||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||
Buff& buff = *itr;
|
||||
if (buff.buff_uniid == buff_uniid) {
|
||||
buff_id = buff.meta->buff_id();
|
||||
removed_buffs.push_back(std::make_tuple(buff.meta, buff.GetCaster().Get()));
|
||||
OnBuffRemove(buff);
|
||||
buff.UnInit();
|
||||
auto buff = *itr;
|
||||
if (buff->buff_uniid == buff_uniid) {
|
||||
buff_id = buff->meta->buff_id();
|
||||
removed_buffs.push_back(std::make_tuple(buff->meta, buff->GetCaster().Get()));
|
||||
OnBuffRemove(*buff.get());
|
||||
buff->UnInit();
|
||||
buff_list_.erase(itr);
|
||||
break;
|
||||
}
|
||||
@ -495,25 +496,25 @@ void Creature::RecalcBuffAttr()
|
||||
ability_->Clear();
|
||||
bool need_refresh_hp = false;
|
||||
for (auto& buff : buff_list_) {
|
||||
if (buff.meta->buff_effect() == kBET_ChgAttr ||
|
||||
buff.meta->buff_effect() == kBET_Car ||
|
||||
buff.meta->buff_effect() == kBET_CrazyMode) {
|
||||
int attr_type = (int)buff.meta->_param1;
|
||||
int calc_type = (int)buff.meta->_param2;
|
||||
if (buff->meta->buff_effect() == kBET_ChgAttr ||
|
||||
buff->meta->buff_effect() == kBET_Car ||
|
||||
buff->meta->buff_effect() == kBET_CrazyMode) {
|
||||
int attr_type = (int)buff->meta->_param1;
|
||||
int calc_type = (int)buff->meta->_param2;
|
||||
if (IsValidHumanAttr(attr_type)) {
|
||||
if (calc_type == 1) {
|
||||
float* p = ability_->GetBuffAttrAbsPtr(attr_type);
|
||||
if (p) {
|
||||
*p += buff.meta->_param3;
|
||||
*p += buff->meta->_param3;
|
||||
}
|
||||
} else if (calc_type == 2) {
|
||||
float* p = ability_->GetBuffAttrRatePtr(attr_type);
|
||||
if (p) {
|
||||
*p += buff.meta->_param3;
|
||||
*p += buff->meta->_param3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buff.add_frameno == room->GetFrameNo() &&
|
||||
if (buff->add_frameno == room->GetFrameNo() &&
|
||||
attr_type == kHAT_MaxHp) {
|
||||
need_refresh_hp = true;
|
||||
}
|
||||
@ -648,9 +649,9 @@ void Creature::RemoveBuffByEffectId(int buff_effect_id)
|
||||
|
||||
void Creature::ClearBuffList()
|
||||
{
|
||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||
list_del_init(&itr->effect_entry);
|
||||
OnBuffRemove(*itr);
|
||||
for (auto buff : buff_list_) {
|
||||
list_del_init(&buff->effect_entry);
|
||||
OnBuffRemove(*buff.get());
|
||||
}
|
||||
buff_list_.clear();
|
||||
buff_effect_ = {};
|
||||
@ -2753,7 +2754,7 @@ void Creature::TraverseBuff(std::function<void (Buff*, bool&)> func)
|
||||
{
|
||||
bool stop = false;
|
||||
for (auto& buff : buff_list_) {
|
||||
func(&buff, stop);
|
||||
func(buff.get(), stop);
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
@ -2871,8 +2872,8 @@ std::string Creature::DebugOutBuffList()
|
||||
for (auto& itr : buff_list_) {
|
||||
data += a8::Format("buffid:%d effect:%d\n",
|
||||
{
|
||||
itr.meta->buff_id(),
|
||||
itr.meta->buff_effect()
|
||||
itr->meta->buff_id(),
|
||||
itr->meta->buff_effect()
|
||||
});
|
||||
}
|
||||
return data;
|
||||
@ -3018,9 +3019,9 @@ void Creature::OnBattleStart(Room* room)
|
||||
std::vector<int> del_buffs;
|
||||
del_buffs.reserve(buff_list_.size());
|
||||
for (auto& buff : buff_list_) {
|
||||
if (!buff.meta->post_battle_valid()) {
|
||||
if (!buff.skill_meta || buff.skill_meta->skill_type() != kPassiveSkill) {
|
||||
del_buffs.push_back(buff.buff_uniid);
|
||||
if (!buff->meta->post_battle_valid()) {
|
||||
if (!buff->skill_meta || buff->skill_meta->skill_type() != kPassiveSkill) {
|
||||
del_buffs.push_back(buff->buff_uniid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "moveableentity.h"
|
||||
#include "buff.h"
|
||||
#include "weapon.h"
|
||||
|
||||
namespace cs
|
||||
@ -50,6 +49,7 @@ struct HumanAbility
|
||||
float fire_rate = 0.0f;
|
||||
};
|
||||
|
||||
struct Buff;
|
||||
struct BattleDataContext;
|
||||
class Ability;
|
||||
class Skill;
|
||||
@ -350,7 +350,7 @@ private:
|
||||
std::array<list_head, kBET_End> buff_effect_ = {};
|
||||
std::array<list_head, kBET_End> depend_effect_ = {};
|
||||
std::array<list_head, kCondBuffEnd> cond_buffs_ = {};
|
||||
std::list<Buff> buff_list_;
|
||||
std::list<std::shared_ptr<Buff>> buff_list_;
|
||||
std::list<std::tuple<int, Hero*>> slave_heros_;
|
||||
std::list<std::tuple<int, RoomObstacle*>> slave_things_;
|
||||
a8::XTimerWp auto_switch_weapon_timer_;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "movehelper.h"
|
||||
#include "trigger.h"
|
||||
#include "ability.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Equip.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "room.h"
|
||||
#include "car.h"
|
||||
#include "trigger.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Hero.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "human.h"
|
||||
#include "car.h"
|
||||
#include "bullet.h"
|
||||
#include "buff.h"
|
||||
|
||||
#include "mt/Buff.h"
|
||||
#include "mt/Skill.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user