From 1e06c5571b1c0d2e9b28bbb83117ea8ac1bac1e2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 29 Mar 2023 20:20:24 +0800 Subject: [PATCH] add disable times --- server/gameserver/ability.cc | 20 ++++++++++---------- server/gameserver/ability.h | 18 ++++-------------- server/gameserver/buff/callfunc.cc | 27 ++++++++++++++++----------- server/gameserver/buff/callfunc.h | 1 - server/gameserver/constant.h | 10 ++++++++++ server/gameserver/creature.cc | 12 ++++++------ 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index d65eba70..dc68ce30 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -197,7 +197,7 @@ void Ability::Clear() } } - disable_times_ = {}; + switch_times_ = {}; immune_tags_.clear(); } @@ -871,28 +871,28 @@ std::vector Ability::GMShowAttrs() return strings; } -void Ability::IncDisable(int type) +void Ability::IncSwitch(int type) { - if (type >= kDisableTimeBegin && type < kDisableTimeEnd) { - ++disable_times_[type]; + if (type >= kSwitchTimeBegin && type < kSwitchTimeEnd) { + ++switch_times_[type]; } else { abort(); } } -void Ability::DecDisable(int type) +void Ability::DecSwitch(int type) { - if (type >= kDisableTimeBegin && type < kDisableTimeEnd) { - --disable_times_[type]; + if (type >= kSwitchTimeBegin && type < kSwitchTimeEnd) { + --switch_times_[type]; } else { abort(); } } -int Ability::GetDisableTimes(int type) +int Ability::GetSwitchTimes(int type) { - if (type >= kDisableTimeBegin && type < kDisableTimeEnd) { - return disable_times_[type]; + if (type >= kSwitchTimeBegin && type < kSwitchTimeEnd) { + return switch_times_[type]; } else { abort(); } diff --git a/server/gameserver/ability.h b/server/gameserver/ability.h index 79adad68..6b598899 100644 --- a/server/gameserver/ability.h +++ b/server/gameserver/ability.h @@ -1,5 +1,4 @@ #pragma once - #include "attrdefine.h" #include "weakptr.h" @@ -8,15 +7,6 @@ typedef std::weak_ptr AttrRuduceHandle; typedef std::weak_ptr AttrAbsHandle; typedef std::weak_ptr AttrRateHandle; -enum DisableTimesType_e -{ - kDisableTimeBegin, - kDisableShotTimes, - kDisableUseSkillTimes, - kDisableMoveEffectTimes, - kDisableTimeEnd, -}; - class Ability { public: @@ -26,9 +16,9 @@ class Ability void DecImmuneTimes(int tag); bool CanImmune(int tag); bool CanImmune(const std::set& tags); - void IncDisable(int type); - void DecDisable(int type); - int GetDisableTimes(int type); + void IncSwitch(int type); + void DecSwitch(int type); + int GetSwitchTimes(int type); AttrAbsHandle AddAttrAbs(int attr_id, float value); void RemoveAttrAbs(AttrAbsHandle handle); @@ -63,7 +53,7 @@ private: std::array, kHAT_End> attr_dec_ = {}; std::array, kHVAT_End - kHVAT_Begin> vattr_add_ = {}; std::array, kHVAT_End - kHVAT_Begin> vattr_dec_ = {}; - std::array disable_times_ = {}; + std::array switch_times_ = {}; std::map immune_tags_; friend class PBUtils; diff --git a/server/gameserver/buff/callfunc.cc b/server/gameserver/buff/callfunc.cc index 4a44c6f9..36c591be 100644 --- a/server/gameserver/buff/callfunc.cc +++ b/server/gameserver/buff/callfunc.cc @@ -117,12 +117,12 @@ void CallFuncBuff::Activate() break; case BuffCallFunc_e::kImmuneAllMove: { - owner->GetAbility()->IncDisable(kDisableMoveEffectTimes); + owner->GetAbility()->IncSwitch(kDisableMoveEffectTimes); } break; case BuffCallFunc_e::kDmgForward: { - DmgForward(); + owner->GetAbility()->IncSwitch(kEnableDmgForwardTimes); } break; default: @@ -150,7 +150,12 @@ void CallFuncBuff::Deactivate() break; case BuffCallFunc_e::kImmuneAllMove: { - owner->GetAbility()->DecDisable(kDisableMoveEffectTimes); + owner->GetAbility()->DecSwitch(kDisableMoveEffectTimes); + } + break; + case BuffCallFunc_e::kDmgForward: + { + owner->GetAbility()->DecSwitch(kEnableDmgForwardTimes); } break; default: @@ -598,20 +603,20 @@ void CallFuncBuff::ProcSyncProp() void CallFuncBuff::SummonHeroSpecPoint() { - + int hero_id = meta->_int_buff_param2; + float x = meta->GetBuffParam3(this); + float y = meta->GetBuffParam4(this); + float z = meta->GetBuffParam5(this); } void CallFuncBuff::SummonHeroSpecDistance() { - + int hero_id = meta->_int_buff_param2; + float distance = meta->GetBuffParam3(this); } void CallFuncBuff::ClearSummonHero() { - -} - -void CallFuncBuff::DmgForward() -{ - + int hero_id = meta->_int_buff_param2; + float hero_num = meta->GetBuffParam3(this); } diff --git a/server/gameserver/buff/callfunc.h b/server/gameserver/buff/callfunc.h index d4bf61ae..9a4c5ad8 100644 --- a/server/gameserver/buff/callfunc.h +++ b/server/gameserver/buff/callfunc.h @@ -44,7 +44,6 @@ class CallFuncBuff : public Buff void SummonHeroSpecPoint(); void SummonHeroSpecDistance(); void ClearSummonHero(); - void DmgForward(); float hold_param2_ = 0.0; }; diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 17d14246..1ac7747a 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -456,6 +456,16 @@ A8_DECLARE_ENUM(WorldObjectType_e, kBornPointType = 4 ); +enum SwitchTimesType_e +{ + kSwitchTimeBegin, + kDisableShotTimes, + kDisableUseSkillTimes, + kDisableMoveEffectTimes, + kEnableDmgForwardTimes, + kSwitchTimeEnd, +}; + const char* const PROJ_NAME_FMT = "game%d_gameserver"; const char* const PROJ_ROOT_FMT = "/data/logs/%s"; diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 6bbaa8b6..03600c22 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -254,10 +254,10 @@ int Creature::AddBuff(Creature* caster, IncDisableMoveDirTimes(); } if (buff->meta->disable_shot()) { - GetAbility()->IncDisable(kDisableShotTimes); + GetAbility()->IncSwitch(kDisableShotTimes); } if (buff->meta->disable_useskill()) { - GetAbility()->IncDisable(kDisableUseSkillTimes); + GetAbility()->IncSwitch(kDisableUseSkillTimes); } list_add_tail(&buff->effect_entry, &buff_effect_[buff->meta->buff_effect()]); if (buff->meta->depend_effect() != 0 && @@ -641,10 +641,10 @@ void Creature::OnBuffRemove(Buff& buff) DecDisableMoveDirTimes(); } if (buff.meta->disable_shot()) { - GetAbility()->DecDisable(kDisableShotTimes); + GetAbility()->DecSwitch(kDisableShotTimes); } if (buff.meta->disable_useskill()) { - GetAbility()->DecDisable(kDisableUseSkillTimes); + GetAbility()->DecSwitch(kDisableUseSkillTimes); } buff.Deactivate(); if (!buff.meta->only_server()) { @@ -795,7 +795,7 @@ bool Creature::CanUseSkill(int skill_id) if (!skill) { return false; } - if (GetAbility()->GetDisableTimes(kDisableUseSkillTimes) > 0) { + if (GetAbility()->GetSwitchTimes(kDisableUseSkillTimes) > 0) { return false; } if (room->GetGasData().GetGasMode() == GasInactive && @@ -1249,7 +1249,7 @@ void Creature::Shot(glm::vec3& target_dir, bool& shot_ok, float fly_distance, in return; } - if (GetAbility()->GetDisableTimes(kDisableShotTimes) > 0) { + if (GetAbility()->GetSwitchTimes(kDisableShotTimes) > 0) { return; }