This commit is contained in:
aozhiwei 2021-03-18 16:38:35 +08:00
parent 3da0b2a3b9
commit 8c15de01a9
6 changed files with 47 additions and 11 deletions

View File

@ -3,6 +3,7 @@
#include "creature.h"
#include "metamgr.h"
#include "room.h"
#include "skill.h"
bool Creature::HasBuffEffect(int buff_effect_id)
{
@ -314,3 +315,18 @@ void Creature::TriggerOneObjectBuff(Entity* target, BuffTriggerType_e trigger_ty
{
}
Skill* Creature::GetSkill(int skill_id)
{
auto itr = skill_hash_.find(skill_id);
return itr != skill_hash_.end() ? itr->second : nullptr;
}
bool Creature::CanUseSkill(int skill_id)
{
Skill* skill = GetSkill(skill_id);
if (!skill) {
return false;
}
return skill->GetLeftTime() <= 0;
}

View File

@ -11,6 +11,7 @@ namespace MetaData
}
struct xtimer_list;
class Skill;
class Creature : public MoveableEntity
{
public:
@ -35,6 +36,7 @@ class Creature : public MoveableEntity
float GetBuffAttrRate(int attr_id);
void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list);
void TriggerBuff(std::set<Entity*>& target_list, BuffTriggerType_e trigger_type);
Skill* GetSkill(int skill_id);
void AddPassiveSkill(MetaData::Skill* skill_meta);
void RemovePassiveSkill(MetaData::Skill* skill_meta);
@ -44,6 +46,7 @@ class Creature : public MoveableEntity
void AddPassiveSkillBuff(MetaData::Skill* skill_meta);
virtual void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
virtual bool CanUseSkill(int skill_id);
protected:
size_t curr_skill_phase = 0;
@ -56,6 +59,7 @@ protected:
long long last_use_skill_frameno_ = 0;
a8::XTimerAttacher skill_xtimer_attacher_;
MetaData::Skill* skill_meta_ = nullptr;
std::map<int, Skill*> skill_hash_;
private:

View File

@ -1314,16 +1314,7 @@ bool Human::HasNoDownedTeammate()
bool Human::CanUseSkill(int skill_id)
{
if (downed) {
return false;
}
if (!skill_meta_) {
return false;
}
if (GetSkillLeftTime() > 0) {
return false;
}
return true;
return !downed && Creature::CanUseSkill(skill_id);
}
void Human::DoJump()

View File

@ -193,7 +193,7 @@ class Human : public Creature
void RemoveOutObjects(Entity* entity);
bool HasLiveTeammate();
bool HasNoDownedTeammate();
bool CanUseSkill(int skill_id);
virtual bool CanUseSkill(int skill_id) override;
void DoJump();
void DoSkill(int skill_id, int target_id, const a8::Vec2& target_pos);
virtual int SelectSkillId();

View File

@ -0,0 +1,8 @@
#include "precompile.h"
#include "skill.h"
int Skill::GetLeftTime()
{
return 0;
}

17
server/gameserver/skill.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
namespace MetaData
{
struct Skill;
}
class Creature;
class Skill
{
public:
Creature* owner = nullptr;
MetaData::Skill* meta = nullptr;
long long add_frameno = 0;
int GetLeftTime();
};