1
This commit is contained in:
parent
395a2a1a88
commit
a722f25f52
@ -6,6 +6,13 @@
|
||||
|
||||
#include "mt/Buff.h"
|
||||
|
||||
/*
|
||||
装备武器
|
||||
子弹命中
|
||||
击杀
|
||||
子弹结束
|
||||
*/
|
||||
|
||||
void CondAddBuff::Activate()
|
||||
{
|
||||
}
|
||||
|
@ -2,6 +2,15 @@
|
||||
|
||||
#include "buff.h"
|
||||
|
||||
#if 0
|
||||
A8_DECLARE_CLASS_ENUM(CondAddBuff_e, int,
|
||||
kBulletHit = 11,
|
||||
kBulletKill = 12,
|
||||
kBulletEnd = 13,
|
||||
kEnd
|
||||
);
|
||||
#endif
|
||||
|
||||
class CondAddBuff : public Buff
|
||||
{
|
||||
public:
|
||||
|
@ -12,17 +12,17 @@
|
||||
|
||||
void EventAddBuff::Activate()
|
||||
{
|
||||
if (!IsValidCondBuff(meta->_int_buff_param1)) {
|
||||
if (!IsValidEventBuff(meta->_int_buff_param1)) {
|
||||
A8_ABORT();
|
||||
}
|
||||
list_add_tail(&cond_entry, &owner->cond_buffs_[meta->_int_buff_param1]);
|
||||
switch (meta->_int_buff_param1) {
|
||||
case kCondBuffDisengageBattle:
|
||||
case kEventBuffDisengageBattle:
|
||||
{
|
||||
ProcDisengageBattle();
|
||||
}
|
||||
break;
|
||||
case kCondBuffLimitTimeKillTarget:
|
||||
case kEventBuffLimitTimeKillTarget:
|
||||
{
|
||||
ProcLimitTimeSkillTarget();
|
||||
}
|
||||
|
@ -331,26 +331,26 @@ enum ExplosionHit_e
|
||||
kExplosionHitEatDmg = 4,
|
||||
};
|
||||
|
||||
enum CondAddBuff_e
|
||||
enum EventAddBuff_e
|
||||
{
|
||||
kCondBuffUpdateWeaponId = 1,
|
||||
kCondBuffUpdateWeaponSlot = 2,
|
||||
kCondBuffUpdateWeaponType = 3,
|
||||
kCondBuffShotWeaponId = 4,
|
||||
kCondBuffShotWeaponSlot = 5,
|
||||
kCondBuffShotWeaponType = 6,
|
||||
kCondBuffKillTarget = 7,
|
||||
kCondBuffDid = 8,
|
||||
kCondBuffUpdateBuffId = 9,
|
||||
kCondBuffUpdateBuffEffect = 10,
|
||||
kCondBuffHp = 11,
|
||||
kCondBuffDown = 12,
|
||||
kCondBuffReceiveDmg = 13,
|
||||
kCondBuffUseSkill = 14,
|
||||
kCondBuffEatDrug = 15,
|
||||
kCondBuffDisengageBattle = 16,
|
||||
kCondBuffLimitTimeKillTarget = 17,
|
||||
kCondBuffEnd
|
||||
kEventBuffUpdateWeaponId = 1,
|
||||
kEventBuffUpdateWeaponSlot = 2,
|
||||
kEventBuffUpdateWeaponType = 3,
|
||||
kEventBuffShotWeaponId = 4,
|
||||
kEventBuffShotWeaponSlot = 5,
|
||||
kEventBuffShotWeaponType = 6,
|
||||
kEventBuffKillTarget = 7,
|
||||
kEventBuffDid = 8,
|
||||
kEventBuffUpdateBuffId = 9,
|
||||
kEventBuffUpdateBuffEffect = 10,
|
||||
kEventBuffHp = 11,
|
||||
kEventBuffDown = 12,
|
||||
kEventBuffReceiveDmg = 13,
|
||||
kEventBuffUseSkill = 14,
|
||||
kEventBuffEatDrug = 15,
|
||||
kEventBuffDisengageBattle = 16,
|
||||
kEventBuffLimitTimeKillTarget = 17,
|
||||
kEventBuffEnd
|
||||
};
|
||||
|
||||
enum WeaponOpt_e
|
||||
|
@ -390,7 +390,7 @@ private:
|
||||
int buff_uniid_ = 1000;
|
||||
std::array<list_head, kBET_End> buff_effect_ = {};
|
||||
std::array<list_head, kBET_End> depend_effect_ = {};
|
||||
std::array<list_head, kCondBuffEnd> cond_buffs_ = {};
|
||||
std::array<list_head, kEventBuffEnd> cond_buffs_ = {};
|
||||
std::list<std::shared_ptr<Buff>> buff_list_;
|
||||
std::map<int, std::shared_ptr<Effect>> effect_hash_;
|
||||
std::list<std::tuple<int, Hero*>> slave_heros_;
|
||||
|
@ -23,9 +23,9 @@ bool IsValidHumanAttr(int attr_type)
|
||||
return attr_type > kHAT_Begin && attr_type < kHAT_End;
|
||||
}
|
||||
|
||||
bool IsValidCondBuff(int cond)
|
||||
bool IsValidEventBuff(int event)
|
||||
{
|
||||
return cond >= 0 && cond < kCondBuffEnd;
|
||||
return event >= 0 && event < kEventBuffEnd;
|
||||
}
|
||||
|
||||
bool IsValidWeaponOpt(int opt)
|
||||
|
@ -21,7 +21,7 @@ class Global : public a8::Singleton<Global>
|
||||
bool IsValidSlotId(int slot_id);
|
||||
bool IsValidBuffEffect(int buff_effect);
|
||||
bool IsValidHumanAttr(int attr_type);
|
||||
bool IsValidCondBuff(int cond);
|
||||
bool IsValidEventBuff(int event);
|
||||
bool IsValidWeaponOpt(int opt);
|
||||
bool IsValidBuffOpt(int opt);
|
||||
float GetAttrAbsFromXObject(std::shared_ptr<a8::XObject> obj, int attr_id);
|
||||
|
@ -246,7 +246,7 @@ namespace mt
|
||||
}
|
||||
}
|
||||
if (buff_effect() == kBET_EventAdd) {
|
||||
if (!IsValidCondBuff(_int_buff_param1)) {
|
||||
if (!IsValidEventBuff(_int_buff_param1)) {
|
||||
A8_ABORT();
|
||||
}
|
||||
}
|
||||
@ -323,15 +323,15 @@ namespace mt
|
||||
return _immune_buffeffect.find(buff_effect) != _immune_buffeffect.end();
|
||||
}
|
||||
|
||||
bool Buff::Match(CondAddBuff_e cond, int val) const
|
||||
bool Buff::Match(EventAddBuff_e event, int val) const
|
||||
{
|
||||
switch (cond) {
|
||||
case kCondBuffUpdateBuffId:
|
||||
switch (event) {
|
||||
case kEventBuffUpdateBuffId:
|
||||
{
|
||||
return val == buff_id();
|
||||
}
|
||||
break;
|
||||
case kCondBuffUpdateBuffEffect:
|
||||
case kEventBuffUpdateBuffEffect:
|
||||
{
|
||||
return val == buff_effect();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace mt
|
||||
void Init2();
|
||||
bool EffectCanStack() const;
|
||||
bool IsImmuneBuffEffect(int buff_effect) const;
|
||||
bool Match(CondAddBuff_e cond, int val) const;
|
||||
bool Match(EventAddBuff_e cond, int val) const;
|
||||
|
||||
float _buff_param1 = 0.0f;
|
||||
float _buff_param2 = 0.0f;
|
||||
|
@ -242,23 +242,23 @@ namespace mt
|
||||
return weapon_idx;
|
||||
}
|
||||
|
||||
bool Equip::Match(CondAddBuff_e cond, int val, int val2) const
|
||||
bool Equip::Match(EventAddBuff_e event, int val, int val2) const
|
||||
{
|
||||
switch (cond) {
|
||||
case kCondBuffUpdateWeaponId:
|
||||
case kCondBuffShotWeaponId:
|
||||
switch (event) {
|
||||
case kEventBuffUpdateWeaponId:
|
||||
case kEventBuffShotWeaponId:
|
||||
{
|
||||
return val == id();
|
||||
}
|
||||
break;
|
||||
case kCondBuffUpdateWeaponSlot:
|
||||
case kCondBuffShotWeaponSlot:
|
||||
case kEventBuffUpdateWeaponSlot:
|
||||
case kEventBuffShotWeaponSlot:
|
||||
{
|
||||
return val == _inventory_slot();
|
||||
}
|
||||
break;
|
||||
case kCondBuffUpdateWeaponType:
|
||||
case kCondBuffShotWeaponType:
|
||||
case kEventBuffUpdateWeaponType:
|
||||
case kEventBuffShotWeaponType:
|
||||
{
|
||||
return val == equip_subtype() &&
|
||||
(val2 == 0 || val2 == equip_type());
|
||||
|
@ -38,7 +38,7 @@ namespace mt
|
||||
void Init1();
|
||||
void Init2();
|
||||
int GetWeaponIdx() const;
|
||||
bool Match(CondAddBuff_e cond, int val, int val2) const;
|
||||
bool Match(EventAddBuff_e event, int val, int val2) const;
|
||||
static const Equip* GetByIdBySlotId(int slot_id);
|
||||
|
||||
private:
|
||||
|
@ -40,12 +40,12 @@ void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
||||
{
|
||||
const mt::Equip* weapon_meta = old_weapon ? old_weapon->meta : nullptr;
|
||||
if (weapon_meta) {
|
||||
for (int cond = kCondBuffUpdateWeaponId; cond <= kCondBuffUpdateWeaponType; cond++) {
|
||||
for (int cond = kEventBuffUpdateWeaponId; cond <= kEventBuffUpdateWeaponType; cond++) {
|
||||
TraverseCondBuffs
|
||||
(cond,
|
||||
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (weapon_meta->Match((CondAddBuff_e)cond,
|
||||
if (weapon_meta->Match((EventAddBuff_e)cond,
|
||||
buff->meta->_int_buff_param3,
|
||||
buff->meta->_int_buff_param5)) {
|
||||
switch (buff->meta->_int_buff_param2) {
|
||||
@ -68,12 +68,12 @@ void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
||||
{
|
||||
const mt::Equip* weapon_meta = new_weapon ? new_weapon->meta : nullptr;
|
||||
if (weapon_meta) {
|
||||
for (int cond = kCondBuffUpdateWeaponId; cond <= kCondBuffUpdateWeaponType; cond++) {
|
||||
for (int cond = kEventBuffUpdateWeaponId; cond <= kEventBuffUpdateWeaponType; cond++) {
|
||||
TraverseCondBuffs
|
||||
(cond,
|
||||
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (weapon_meta->Match((CondAddBuff_e)cond,
|
||||
if (weapon_meta->Match((EventAddBuff_e)cond,
|
||||
buff->meta->_int_buff_param3,
|
||||
buff->meta->_int_buff_param5)) {
|
||||
switch (buff->meta->_int_buff_param2) {
|
||||
@ -102,12 +102,12 @@ void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
||||
|
||||
void Trigger::Shot(const mt::Equip* weapon_meta)
|
||||
{
|
||||
for (int cond = kCondBuffShotWeaponId; cond <= kCondBuffShotWeaponType; ++cond) {
|
||||
for (int cond = kEventBuffShotWeaponId; cond <= kEventBuffShotWeaponType; ++cond) {
|
||||
TraverseCondBuffs
|
||||
(cond,
|
||||
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (weapon_meta->Match((CondAddBuff_e)cond,
|
||||
if (weapon_meta->Match((EventAddBuff_e)cond,
|
||||
buff->meta->_int_buff_param2,
|
||||
buff->meta->_int_buff_param5)) {
|
||||
AddBuffs(buff->meta->_int_buff_param1, buff->meta->_buff_param4_int_list);
|
||||
@ -149,7 +149,7 @@ void Trigger::Kill(Creature* target, int weapon_id)
|
||||
}
|
||||
++kill_num_;
|
||||
TraverseCondBuffs
|
||||
(kCondBuffKillTarget,
|
||||
(kEventBuffKillTarget,
|
||||
[this] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (buff->meta->_int_buff_param2 > 0 && (kill_num_ % buff->meta->_int_buff_param2) == 0) {
|
||||
@ -162,7 +162,7 @@ void Trigger::Kill(Creature* target, int weapon_id)
|
||||
void Trigger::UseItemAction(int slot_id)
|
||||
{
|
||||
TraverseCondBuffs
|
||||
(kCondBuffEatDrug,
|
||||
(kEventBuffEatDrug,
|
||||
[this, slot_id] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (buff->meta->_buff_param2_int_set.find(slot_id) != buff->meta->_buff_param2_int_set.end()) {
|
||||
@ -174,7 +174,7 @@ void Trigger::UseItemAction(int slot_id)
|
||||
void Trigger::UseSkill(Skill* skill)
|
||||
{
|
||||
TraverseCondBuffs
|
||||
(kCondBuffUseSkill,
|
||||
(kEventBuffUseSkill,
|
||||
[this, skill] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (buff->meta->_int_buff_param2 == skill->meta->skill_id()) {
|
||||
@ -187,7 +187,7 @@ void Trigger::UseSkill(Skill* skill)
|
||||
void Trigger::HpChg()
|
||||
{
|
||||
TraverseCondBuffs
|
||||
(kCondBuffHp,
|
||||
(kEventBuffHp,
|
||||
[this] (Buff* buff, bool& stop)
|
||||
{
|
||||
bool match = false;
|
||||
@ -230,7 +230,7 @@ void Trigger::HpChg()
|
||||
|
||||
void Trigger::ReceiveDmg()
|
||||
{
|
||||
TriggeCondBuffAll(kCondBuffReceiveDmg);
|
||||
TriggeCondBuffAll(kEventBuffReceiveDmg);
|
||||
DispatchEvent(kReceiveDmgEvent, {});
|
||||
}
|
||||
|
||||
@ -255,13 +255,13 @@ void Trigger::Die(int killer_id, int weapon_id)
|
||||
owner_->RemoveBuffByUniId(buff_uniid);
|
||||
}
|
||||
}
|
||||
TriggeCondBuffAll(kCondBuffDid);
|
||||
TriggeCondBuffAll(kEventBuffDid);
|
||||
DispatchEvent(kDieEvent, {killer_id, weapon_id});
|
||||
}
|
||||
|
||||
void Trigger::TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func)
|
||||
{
|
||||
if (!IsValidCondBuff(cond)) {
|
||||
if (!IsValidEventBuff(cond)) {
|
||||
A8_ABORT();
|
||||
}
|
||||
if (!owner_->room->BattleStarted()) {
|
||||
@ -315,12 +315,12 @@ void Trigger::TriggeCondBuffAll(int cond)
|
||||
|
||||
void Trigger::ActiveBuff(const mt::Buff* buff_meta)
|
||||
{
|
||||
for (int cond = kCondBuffUpdateBuffId; cond <= kCondBuffUpdateBuffEffect; ++cond) {
|
||||
for (int cond = kEventBuffUpdateBuffId; cond <= kEventBuffUpdateBuffEffect; ++cond) {
|
||||
TraverseCondBuffs
|
||||
(cond,
|
||||
[this, cond, buff_meta] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (buff_meta->Match((CondAddBuff_e)cond, buff->meta->_int_buff_param3)) {
|
||||
if (buff_meta->Match((EventAddBuff_e)cond, buff->meta->_int_buff_param3)) {
|
||||
switch (buff->meta->_int_buff_param2) {
|
||||
case kBuffOptActive:
|
||||
{
|
||||
@ -344,12 +344,12 @@ void Trigger::ActiveBuff(const mt::Buff* buff_meta)
|
||||
|
||||
void Trigger::DeactiveBuff(const mt::Buff* buff_meta)
|
||||
{
|
||||
for (int cond = kCondBuffUpdateBuffId; cond <= kCondBuffUpdateBuffEffect; ++cond) {
|
||||
for (int cond = kEventBuffUpdateBuffId; cond <= kEventBuffUpdateBuffEffect; ++cond) {
|
||||
TraverseCondBuffs
|
||||
(cond,
|
||||
[this, cond, buff_meta] (Buff* buff, bool& stop)
|
||||
{
|
||||
if (buff_meta->Match((CondAddBuff_e)cond, buff->meta->_int_buff_param3)) {
|
||||
if (buff_meta->Match((EventAddBuff_e)cond, buff->meta->_int_buff_param3)) {
|
||||
switch (buff->meta->_int_buff_param2) {
|
||||
case kBuffOptDeactive:
|
||||
case kBuffOptKeep:
|
||||
|
Loading…
x
Reference in New Issue
Block a user