diff --git a/server/gameserver/buff/cond_add.cc b/server/gameserver/buff/cond_add.cc index 19aa98db..36ca6891 100644 --- a/server/gameserver/buff/cond_add.cc +++ b/server/gameserver/buff/cond_add.cc @@ -6,6 +6,13 @@ #include "mt/Buff.h" +/* + 装备武器 + 子弹命中 + 击杀 + 子弹结束 + */ + void CondAddBuff::Activate() { } diff --git a/server/gameserver/buff/cond_add.h b/server/gameserver/buff/cond_add.h index d809937b..9309d1b1 100644 --- a/server/gameserver/buff/cond_add.h +++ b/server/gameserver/buff/cond_add.h @@ -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: diff --git a/server/gameserver/buff/event_add.cc b/server/gameserver/buff/event_add.cc index 5a46216e..9fcc0623 100644 --- a/server/gameserver/buff/event_add.cc +++ b/server/gameserver/buff/event_add.cc @@ -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(); } diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 62cd674f..e9224f9f 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -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 diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index b1e25114..bc1fe259 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -390,7 +390,7 @@ private: int buff_uniid_ = 1000; std::array buff_effect_ = {}; std::array depend_effect_ = {}; - std::array cond_buffs_ = {}; + std::array cond_buffs_ = {}; std::list> buff_list_; std::map> effect_hash_; std::list> slave_heros_; diff --git a/server/gameserver/global.cc b/server/gameserver/global.cc index 676c4799..1b43fe0c 100644 --- a/server/gameserver/global.cc +++ b/server/gameserver/global.cc @@ -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) diff --git a/server/gameserver/global.h b/server/gameserver/global.h index 156cd144..566ab37b 100644 --- a/server/gameserver/global.h +++ b/server/gameserver/global.h @@ -21,7 +21,7 @@ class Global : public a8::Singleton 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 obj, int attr_id); diff --git a/server/gameserver/mt/Buff.cc b/server/gameserver/mt/Buff.cc index 1b50fb27..31fe63ef 100644 --- a/server/gameserver/mt/Buff.cc +++ b/server/gameserver/mt/Buff.cc @@ -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(); } diff --git a/server/gameserver/mt/Buff.h b/server/gameserver/mt/Buff.h index b81b8e17..d22108f3 100644 --- a/server/gameserver/mt/Buff.h +++ b/server/gameserver/mt/Buff.h @@ -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; diff --git a/server/gameserver/mt/Equip.cc b/server/gameserver/mt/Equip.cc index 376873eb..16ef1af6 100644 --- a/server/gameserver/mt/Equip.cc +++ b/server/gameserver/mt/Equip.cc @@ -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()); diff --git a/server/gameserver/mt/Equip.h b/server/gameserver/mt/Equip.h index 1c662093..50cc7089 100644 --- a/server/gameserver/mt/Equip.h +++ b/server/gameserver/mt/Equip.h @@ -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: diff --git a/server/gameserver/trigger.cc b/server/gameserver/trigger.cc index ebaea2eb..19ba44bc 100644 --- a/server/gameserver/trigger.cc +++ b/server/gameserver/trigger.cc @@ -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 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: