1
This commit is contained in:
parent
a82513cd61
commit
700795c533
@ -4,6 +4,7 @@
|
|||||||
#include "creature.h"
|
#include "creature.h"
|
||||||
#include "battledatacontext.h"
|
#include "battledatacontext.h"
|
||||||
#include "trigger.h"
|
#include "trigger.h"
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
#include "mt/GraspBuff.h"
|
#include "mt/GraspBuff.h"
|
||||||
#include "mt/Grasp.h"
|
#include "mt/Grasp.h"
|
||||||
@ -14,6 +15,7 @@ struct GraspBuff
|
|||||||
list_head entry;
|
list_head entry;
|
||||||
std::tuple<const mt::GraspBuff*, const mt::GraspBuff*> buffs;
|
std::tuple<const mt::GraspBuff*, const mt::GraspBuff*> buffs;
|
||||||
std::function<void()> on_remove;
|
std::function<void()> on_remove;
|
||||||
|
a8::Attacher xtimer_attacher;
|
||||||
|
|
||||||
void ProcSignet(GunGrasp* gun_grasp, int count)
|
void ProcSignet(GunGrasp* gun_grasp, int count)
|
||||||
{
|
{
|
||||||
@ -21,6 +23,20 @@ struct GraspBuff
|
|||||||
const mt::GraspBuff* buff2_meta = std::get<1>(buffs);
|
const mt::GraspBuff* buff2_meta = std::get<1>(buffs);
|
||||||
if (buff1_meta && buff2_meta) {
|
if (buff1_meta && buff2_meta) {
|
||||||
gun_grasp->AddSignet(buff1_meta->graspbuff_id(), count);
|
gun_grasp->AddSignet(buff1_meta->graspbuff_id(), count);
|
||||||
|
if (buff1_meta) {
|
||||||
|
int buff_time = buff1_meta->GetBuffTime(gun_grasp->GetHeroLv());
|
||||||
|
if (buff_time < 9999) {
|
||||||
|
gun_grasp->GetOwner()->room->xtimer.SetTimeoutEx
|
||||||
|
(
|
||||||
|
buff_time * SERVER_FRAME_RATE,
|
||||||
|
[] (int event, const a8::Args* args)
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
&xtimer_attacher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,13 +63,12 @@ void GunGrasp::Clear()
|
|||||||
void GunGrasp::InstallTriggers()
|
void GunGrasp::InstallTriggers()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
int hero_lv = 0;
|
|
||||||
int hero_quality = 0;
|
int hero_quality = 0;
|
||||||
owner_->GetBattleContext()->GetHeroLvQuality(hero_lv, hero_quality);
|
owner_->GetBattleContext()->GetHeroLvQuality(hero_lv_, hero_quality);
|
||||||
if (owner_->GetHeroMeta()) {
|
if (owner_->GetHeroMeta()) {
|
||||||
mt::GraspBuffs* buffs = mt::Grasp::GetGrasp
|
mt::GraspBuffs* buffs = mt::Grasp::GetGrasp
|
||||||
(owner_->GetHeroMeta()->id(),
|
(owner_->GetHeroMeta()->id(),
|
||||||
hero_lv,
|
hero_lv_,
|
||||||
owner_->GetCurrWeapon()->weapon_id);
|
owner_->GetCurrWeapon()->weapon_id);
|
||||||
if (buffs) {
|
if (buffs) {
|
||||||
for (auto& tuple : *buffs) {
|
for (auto& tuple : *buffs) {
|
||||||
@ -150,6 +165,14 @@ void GunGrasp::AddSignet(int id, int count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GunGrasp::RemoveSignet(int id, int count)
|
||||||
|
{
|
||||||
|
auto itr = signet_hash_.find(id);
|
||||||
|
if (itr != signet_hash_.end()) {
|
||||||
|
itr->second = std::max(0, itr->second - count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int GunGrasp::GetSignetCount(int id)
|
int GunGrasp::GetSignetCount(int id)
|
||||||
{
|
{
|
||||||
auto itr = signet_hash_.find(id);
|
auto itr = signet_hash_.find(id);
|
||||||
|
@ -11,7 +11,10 @@ class GunGrasp
|
|||||||
void Clear();
|
void Clear();
|
||||||
void InstallTriggers();
|
void InstallTriggers();
|
||||||
void AddSignet(int id, int count);
|
void AddSignet(int id, int count);
|
||||||
|
void RemoveSignet(int id, int count);
|
||||||
bool HasBulletBlockBuff();
|
bool HasBulletBlockBuff();
|
||||||
|
Creature* GetOwner() { return owner_; }
|
||||||
|
int GetHeroLv() { return hero_lv_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ProcHit(GraspBuff* buff);
|
void ProcHit(GraspBuff* buff);
|
||||||
@ -24,6 +27,7 @@ class GunGrasp
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Creature* owner_ = nullptr;
|
Creature* owner_ = nullptr;
|
||||||
|
int hero_lv_ = 0;
|
||||||
std::map<int, int> signet_hash_;
|
std::map<int, int> signet_hash_;
|
||||||
std::array<list_head, (int)GraspBuffTrigger_e::kEnd> grasp_triggers_ = {};
|
std::array<list_head, (int)GraspBuffTrigger_e::kEnd> grasp_triggers_ = {};
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ namespace mt
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GraspBuff::GetBuffTime(int hero_lv)
|
int GraspBuff::GetBuffTime(int hero_lv) const
|
||||||
{
|
{
|
||||||
switch (hero_lv) {
|
switch (hero_lv) {
|
||||||
case 10:
|
case 10:
|
||||||
|
@ -17,7 +17,7 @@ namespace mt
|
|||||||
int _trigger_type = 0;
|
int _trigger_type = 0;
|
||||||
int _trigger_subtype = 0;
|
int _trigger_subtype = 0;
|
||||||
std::vector<int> _trigger_cond;
|
std::vector<int> _trigger_cond;
|
||||||
int GetBuffTime(int hero_lv);
|
int GetBuffTime(int hero_lv) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> _buff_times;
|
std::vector<int> _buff_times;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user