add disable times

This commit is contained in:
aozhiwei 2023-03-29 20:20:24 +08:00
parent 25d9ed524a
commit 1e06c5571b
6 changed files with 46 additions and 42 deletions

View File

@ -197,7 +197,7 @@ void Ability::Clear()
} }
} }
disable_times_ = {}; switch_times_ = {};
immune_tags_.clear(); immune_tags_.clear();
} }
@ -871,28 +871,28 @@ std::vector<std::string> Ability::GMShowAttrs()
return strings; return strings;
} }
void Ability::IncDisable(int type) void Ability::IncSwitch(int type)
{ {
if (type >= kDisableTimeBegin && type < kDisableTimeEnd) { if (type >= kSwitchTimeBegin && type < kSwitchTimeEnd) {
++disable_times_[type]; ++switch_times_[type];
} else { } else {
abort(); abort();
} }
} }
void Ability::DecDisable(int type) void Ability::DecSwitch(int type)
{ {
if (type >= kDisableTimeBegin && type < kDisableTimeEnd) { if (type >= kSwitchTimeBegin && type < kSwitchTimeEnd) {
--disable_times_[type]; --switch_times_[type];
} else { } else {
abort(); abort();
} }
} }
int Ability::GetDisableTimes(int type) int Ability::GetSwitchTimes(int type)
{ {
if (type >= kDisableTimeBegin && type < kDisableTimeEnd) { if (type >= kSwitchTimeBegin && type < kSwitchTimeEnd) {
return disable_times_[type]; return switch_times_[type];
} else { } else {
abort(); abort();
} }

View File

@ -1,5 +1,4 @@
#pragma once #pragma once
#include "attrdefine.h" #include "attrdefine.h"
#include "weakptr.h" #include "weakptr.h"
@ -8,15 +7,6 @@ typedef std::weak_ptr<struct AttrRuducePtr> AttrRuduceHandle;
typedef std::weak_ptr<struct AttrAbsPtr> AttrAbsHandle; typedef std::weak_ptr<struct AttrAbsPtr> AttrAbsHandle;
typedef std::weak_ptr<struct AttrRatePtr> AttrRateHandle; typedef std::weak_ptr<struct AttrRatePtr> AttrRateHandle;
enum DisableTimesType_e
{
kDisableTimeBegin,
kDisableShotTimes,
kDisableUseSkillTimes,
kDisableMoveEffectTimes,
kDisableTimeEnd,
};
class Ability class Ability
{ {
public: public:
@ -26,9 +16,9 @@ class Ability
void DecImmuneTimes(int tag); void DecImmuneTimes(int tag);
bool CanImmune(int tag); bool CanImmune(int tag);
bool CanImmune(const std::set<int>& tags); bool CanImmune(const std::set<int>& tags);
void IncDisable(int type); void IncSwitch(int type);
void DecDisable(int type); void DecSwitch(int type);
int GetDisableTimes(int type); int GetSwitchTimes(int type);
AttrAbsHandle AddAttrAbs(int attr_id, float value); AttrAbsHandle AddAttrAbs(int attr_id, float value);
void RemoveAttrAbs(AttrAbsHandle handle); void RemoveAttrAbs(AttrAbsHandle handle);
@ -63,7 +53,7 @@ private:
std::array<std::tuple<float, list_head>, kHAT_End> attr_dec_ = {}; std::array<std::tuple<float, list_head>, kHAT_End> attr_dec_ = {};
std::array<std::tuple<float, list_head>, kHVAT_End - kHVAT_Begin> vattr_add_ = {}; std::array<std::tuple<float, list_head>, kHVAT_End - kHVAT_Begin> vattr_add_ = {};
std::array<std::tuple<float, list_head>, kHVAT_End - kHVAT_Begin> vattr_dec_ = {}; std::array<std::tuple<float, list_head>, kHVAT_End - kHVAT_Begin> vattr_dec_ = {};
std::array<int, kDisableTimeEnd> disable_times_ = {}; std::array<int, kSwitchTimeEnd> switch_times_ = {};
std::map<int, int> immune_tags_; std::map<int, int> immune_tags_;
friend class PBUtils; friend class PBUtils;

View File

@ -117,12 +117,12 @@ void CallFuncBuff::Activate()
break; break;
case BuffCallFunc_e::kImmuneAllMove: case BuffCallFunc_e::kImmuneAllMove:
{ {
owner->GetAbility()->IncDisable(kDisableMoveEffectTimes); owner->GetAbility()->IncSwitch(kDisableMoveEffectTimes);
} }
break; break;
case BuffCallFunc_e::kDmgForward: case BuffCallFunc_e::kDmgForward:
{ {
DmgForward(); owner->GetAbility()->IncSwitch(kEnableDmgForwardTimes);
} }
break; break;
default: default:
@ -150,7 +150,12 @@ void CallFuncBuff::Deactivate()
break; break;
case BuffCallFunc_e::kImmuneAllMove: case BuffCallFunc_e::kImmuneAllMove:
{ {
owner->GetAbility()->DecDisable(kDisableMoveEffectTimes); owner->GetAbility()->DecSwitch(kDisableMoveEffectTimes);
}
break;
case BuffCallFunc_e::kDmgForward:
{
owner->GetAbility()->DecSwitch(kEnableDmgForwardTimes);
} }
break; break;
default: default:
@ -598,20 +603,20 @@ void CallFuncBuff::ProcSyncProp()
void CallFuncBuff::SummonHeroSpecPoint() 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() void CallFuncBuff::SummonHeroSpecDistance()
{ {
int hero_id = meta->_int_buff_param2;
float distance = meta->GetBuffParam3(this);
} }
void CallFuncBuff::ClearSummonHero() void CallFuncBuff::ClearSummonHero()
{ {
int hero_id = meta->_int_buff_param2;
} float hero_num = meta->GetBuffParam3(this);
void CallFuncBuff::DmgForward()
{
} }

View File

@ -44,7 +44,6 @@ class CallFuncBuff : public Buff
void SummonHeroSpecPoint(); void SummonHeroSpecPoint();
void SummonHeroSpecDistance(); void SummonHeroSpecDistance();
void ClearSummonHero(); void ClearSummonHero();
void DmgForward();
float hold_param2_ = 0.0; float hold_param2_ = 0.0;
}; };

View File

@ -456,6 +456,16 @@ A8_DECLARE_ENUM(WorldObjectType_e,
kBornPointType = 4 kBornPointType = 4
); );
enum SwitchTimesType_e
{
kSwitchTimeBegin,
kDisableShotTimes,
kDisableUseSkillTimes,
kDisableMoveEffectTimes,
kEnableDmgForwardTimes,
kSwitchTimeEnd,
};
const char* const PROJ_NAME_FMT = "game%d_gameserver"; const char* const PROJ_NAME_FMT = "game%d_gameserver";
const char* const PROJ_ROOT_FMT = "/data/logs/%s"; const char* const PROJ_ROOT_FMT = "/data/logs/%s";

View File

@ -254,10 +254,10 @@ int Creature::AddBuff(Creature* caster,
IncDisableMoveDirTimes(); IncDisableMoveDirTimes();
} }
if (buff->meta->disable_shot()) { if (buff->meta->disable_shot()) {
GetAbility()->IncDisable(kDisableShotTimes); GetAbility()->IncSwitch(kDisableShotTimes);
} }
if (buff->meta->disable_useskill()) { if (buff->meta->disable_useskill()) {
GetAbility()->IncDisable(kDisableUseSkillTimes); GetAbility()->IncSwitch(kDisableUseSkillTimes);
} }
list_add_tail(&buff->effect_entry, &buff_effect_[buff->meta->buff_effect()]); list_add_tail(&buff->effect_entry, &buff_effect_[buff->meta->buff_effect()]);
if (buff->meta->depend_effect() != 0 && if (buff->meta->depend_effect() != 0 &&
@ -641,10 +641,10 @@ void Creature::OnBuffRemove(Buff& buff)
DecDisableMoveDirTimes(); DecDisableMoveDirTimes();
} }
if (buff.meta->disable_shot()) { if (buff.meta->disable_shot()) {
GetAbility()->DecDisable(kDisableShotTimes); GetAbility()->DecSwitch(kDisableShotTimes);
} }
if (buff.meta->disable_useskill()) { if (buff.meta->disable_useskill()) {
GetAbility()->DecDisable(kDisableUseSkillTimes); GetAbility()->DecSwitch(kDisableUseSkillTimes);
} }
buff.Deactivate(); buff.Deactivate();
if (!buff.meta->only_server()) { if (!buff.meta->only_server()) {
@ -795,7 +795,7 @@ bool Creature::CanUseSkill(int skill_id)
if (!skill) { if (!skill) {
return false; return false;
} }
if (GetAbility()->GetDisableTimes(kDisableUseSkillTimes) > 0) { if (GetAbility()->GetSwitchTimes(kDisableUseSkillTimes) > 0) {
return false; return false;
} }
if (room->GetGasData().GetGasMode() == GasInactive && if (room->GetGasData().GetGasMode() == GasInactive &&
@ -1249,7 +1249,7 @@ void Creature::Shot(glm::vec3& target_dir, bool& shot_ok, float fly_distance, in
return; return;
} }
if (GetAbility()->GetDisableTimes(kDisableShotTimes) > 0) { if (GetAbility()->GetSwitchTimes(kDisableShotTimes) > 0) {
return; return;
} }