This commit is contained in:
aozhiwei 2023-10-19 13:48:56 +08:00
parent da64abb9e2
commit 435499dbdd
3 changed files with 18 additions and 1 deletions

View File

@ -847,12 +847,27 @@ Skill* Creature::GetSkill(int skill_id)
}
}
bool Creature::HasUseableSkill()
{
for (auto& pair : skill_hash_) {
if (InternalCanUseSkill(pair.second.get())) {
return true;
}
}
return false;
}
bool Creature::CanUseSkill(int skill_id)
{
Skill* skill = GetSkill(skill_id);
if (!skill) {
return false;
}
return InternalCanUseSkill(skill);
}
bool Creature::InternalCanUseSkill(Skill* skill)
{
if (skill->GetCurrTimes() <= 0) {
return false;
}

View File

@ -222,6 +222,7 @@ class Creature : public MoveableEntity
const Position& target_pos,
std::set<Creature*>& target_list);
virtual bool CanUseSkill(int skill_id);
bool HasUseableSkill();
void DoSkill(int skill_id,
int target_id,
const glm::vec3& skill_dir,
@ -389,6 +390,7 @@ private:
void CheckAbilityUsed();
void AutoSwitchWeapon();
void CheckLoadingBullet();
bool InternalCanUseSkill(Skill* skill);
protected:
bool need_sync_active_player_ = false;

View File

@ -24,7 +24,7 @@ int TargetAgent::GetUniId()
bool TargetAgent::IsValid()
{
return target_.Get() && !target_.Get()->dead && target_.Get()->team_id == owner_->team_id;
return target_.Get() && !target_.Get()->dead && target_.Get()->team_id != owner_->team_id;
}
bool TargetAgent::IsDead()