ai添加机器人
This commit is contained in:
parent
8eec4e7b55
commit
45445369c0
@ -131,6 +131,18 @@ void AndroidAI::DoAttack()
|
|||||||
!enemy->HasBuffEffect(BET_Hide) &&
|
!enemy->HasBuffEffect(BET_Hide) &&
|
||||||
!enemy->HasBuffEffect(BET_InGrass)
|
!enemy->HasBuffEffect(BET_InGrass)
|
||||||
) {
|
) {
|
||||||
|
Human* sender = (Human*)owner;
|
||||||
|
if (sender->CanUseSkill()) {
|
||||||
|
UseSkill(enemy);
|
||||||
|
} else {
|
||||||
|
Shot(enemy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidAI::Shot(Human* enemy)
|
||||||
|
{
|
||||||
Human* sender = (Human*)owner;
|
Human* sender = (Human*)owner;
|
||||||
a8::Vec2 shot_dir = enemy->pos - sender->pos;
|
a8::Vec2 shot_dir = enemy->pos - sender->pos;
|
||||||
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
||||||
@ -146,5 +158,19 @@ void AndroidAI::DoAttack()
|
|||||||
sender->Shot();
|
sender->Shot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidAI::UseSkill(Human* enemy)
|
||||||
|
{
|
||||||
|
Human* sender = (Human*)owner;
|
||||||
|
a8::Vec2 shot_dir = enemy->pos - sender->pos;
|
||||||
|
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
||||||
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
|
sender->curr_skill_phase = 0;
|
||||||
|
sender->skill_target_id = enemy->entity_uniid;
|
||||||
|
sender->skill_dir = shot_dir;
|
||||||
|
sender->skill_target_pos = enemy->pos;
|
||||||
|
sender->skill_param1 = 0;
|
||||||
|
sender->playing_skill = false;
|
||||||
|
sender->DoSkill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,6 @@ private:
|
|||||||
void DoMove();
|
void DoMove();
|
||||||
void DoAttack();
|
void DoAttack();
|
||||||
|
|
||||||
|
void Shot(Human* enemy);
|
||||||
|
void UseSkill(Human* enemy);
|
||||||
};
|
};
|
||||||
|
@ -541,9 +541,26 @@ bool Human::HasLiveTeammate()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Human::CanUseSkill()
|
||||||
|
{
|
||||||
|
if (!skill_meta_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (GetSkillLeftTime() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (a8::HasBitFlag(status, HS_Assaulting) ||
|
||||||
|
HasBuffEffect(BET_Vertigo) ||
|
||||||
|
HasBuffEffect(BET_Dcgr)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Human::DoSkill()
|
void Human::DoSkill()
|
||||||
{
|
{
|
||||||
if (skill_meta_ && GetSkillLeftTime() <= 0 && !a8::HasBitFlag(status, HS_Assaulting)) {
|
if (CanUseSkill()) {
|
||||||
use_skill = false;
|
use_skill = false;
|
||||||
curr_skill_phase = 0;
|
curr_skill_phase = 0;
|
||||||
skill_dir = a8::Vec2();
|
skill_dir = a8::Vec2();
|
||||||
|
@ -136,6 +136,7 @@ class Human : public Entity
|
|||||||
void AddOutObjects(Entity* entity);
|
void AddOutObjects(Entity* entity);
|
||||||
void RemoveOutObjects(Entity* entity);
|
void RemoveOutObjects(Entity* entity);
|
||||||
bool HasLiveTeammate();
|
bool HasLiveTeammate();
|
||||||
|
bool CanUseSkill();
|
||||||
void DoSkill();
|
void DoSkill();
|
||||||
void FindLocation();
|
void FindLocation();
|
||||||
void RefreshView();
|
void RefreshView();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user