324 lines
5.3 KiB
C++
324 lines
5.3 KiB
C++
#include "precompile.h"
|
|
|
|
#include "new_hero_agent.h"
|
|
|
|
#include "hero.h"
|
|
#include "room.h"
|
|
#include "movement.h"
|
|
#include "netdata.h"
|
|
#include "glmhelper.h"
|
|
#include "target_agent.h"
|
|
#include "weapon.h"
|
|
#include "mapinstance.h"
|
|
|
|
#include "mt/Hero.h"
|
|
#include "mt/Equip.h"
|
|
|
|
HeroAgent::HeroAgent():BaseAgent()
|
|
{
|
|
|
|
}
|
|
|
|
HeroAgent::~HeroAgent()
|
|
{
|
|
}
|
|
|
|
void HeroAgent::Exec()
|
|
{
|
|
|
|
}
|
|
|
|
void HeroAgent::SetOwner(Creature* owner)
|
|
{
|
|
room_agent = owner->room->GetRoomAgent();
|
|
owner_ = owner;
|
|
}
|
|
|
|
int HeroAgent::GetUniId()
|
|
{
|
|
return owner_->GetUniId();
|
|
}
|
|
|
|
int HeroAgent::GetAgentType()
|
|
{
|
|
abort();
|
|
}
|
|
|
|
bool HeroAgent::IsMoving()
|
|
{
|
|
return owner_->GetMovement()->GetPathSize() > 0;
|
|
}
|
|
|
|
glm::vec3 HeroAgent::GetPos()
|
|
{
|
|
return owner_->GetPos().ToGlmVec3();
|
|
}
|
|
|
|
bool HeroAgent::IsDead()
|
|
{
|
|
return owner_->dead;
|
|
}
|
|
|
|
glm::vec3 HeroAgent::GetSafeAreaCenter()
|
|
{
|
|
return glm::vec3(
|
|
owner_->room->GetGasData().pos_new.x,
|
|
0.0f,
|
|
owner_->room->GetGasData().pos_new.y
|
|
);
|
|
}
|
|
|
|
float HeroAgent::GetSafeAreaRadius()
|
|
{
|
|
return owner_->room->GetGasData().gas_progress;
|
|
}
|
|
|
|
float HeroAgent::GetHp()
|
|
{
|
|
return owner_->GetHP();
|
|
}
|
|
|
|
float HeroAgent::GetMaxHp()
|
|
{
|
|
return owner_->GetMaxHP();
|
|
}
|
|
|
|
void HeroAgent::OpenBulletTraceMode()
|
|
{
|
|
bullet_trace_mode_ = true;
|
|
}
|
|
|
|
void HeroAgent::CloseBulletTraceMode()
|
|
{
|
|
bullet_trace_mode_ = false;
|
|
}
|
|
|
|
float HeroAgent::CalcDistance(const glm::vec3& target_pos)
|
|
{
|
|
return owner_->GetPos().DistanceGlmVec3(target_pos);
|
|
}
|
|
|
|
int HeroAgent::GetHeroId()
|
|
{
|
|
return owner_->GetHeroMeta()->id();
|
|
}
|
|
|
|
int HeroAgent::GetLevel()
|
|
{
|
|
return owner_->level;
|
|
}
|
|
|
|
bool HeroAgent::CanShot()
|
|
{
|
|
return owner_->CanShot(false);
|
|
}
|
|
|
|
bool HeroAgent::CanUseSkill()
|
|
{
|
|
abort();
|
|
}
|
|
|
|
void HeroAgent::UseSkill(int skill_id)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
void HeroAgent::SendEmote(int emote)
|
|
{
|
|
owner_->room->frame_event.AddEmote(owner_->GetWeakPtrRef(), emote);
|
|
}
|
|
|
|
int HeroAgent::GetBattleTimes()
|
|
{
|
|
return owner_->GetBattleContext()->GetBattleTimes();
|
|
}
|
|
|
|
void HeroAgent::SetMoveDir(const glm::vec3& dir)
|
|
{
|
|
owner_->SetMoveDir(dir);
|
|
}
|
|
|
|
void HeroAgent::SetAttackDir(const glm::vec3& dir)
|
|
{
|
|
owner_->SetAttackDir(dir);
|
|
}
|
|
|
|
void HeroAgent::ShotNormal(const glm::vec3& dir)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
void HeroAgent::ShotTrace()
|
|
{
|
|
abort();
|
|
}
|
|
|
|
glm::vec3 HeroAgent::GetRandomDir()
|
|
{
|
|
glm::vec3 dir = owner_->GetMoveDir();
|
|
GlmHelper::RotateY(dir, (10 + rand() % 360)/ 180.0f);
|
|
return dir;
|
|
}
|
|
|
|
glm::vec3 HeroAgent::GetTargetDir()
|
|
{
|
|
if (current_target_agent->IsValid()) {
|
|
return owner_->GetMoveDir();
|
|
}
|
|
glm::vec3 dir = current_target_agent->GetPos() - owner_->GetPos().ToGlmVec3();
|
|
GlmHelper::Normalize(dir);
|
|
return dir;
|
|
}
|
|
|
|
glm::vec3 HeroAgent::RandomPoint(const glm::vec3& center, float range)
|
|
{
|
|
glm::vec3 hit_point;
|
|
bool hit_result = false;
|
|
|
|
glm::vec3 start = center;
|
|
glm::vec3 dir = GlmHelper::UP;
|
|
GlmHelper::RotateY(dir, (10 + rand() % 360)/ 180.0f);
|
|
GlmHelper::Normalize(dir);
|
|
glm::vec3 end = center + dir * range;
|
|
|
|
owner_->room->map_instance->Scale(start);
|
|
owner_->room->map_instance->Scale(end);
|
|
if (owner_->room->map_instance->Raycast
|
|
(
|
|
start,
|
|
end,
|
|
hit_point,
|
|
hit_result
|
|
)) {
|
|
owner_->room->map_instance->Scale(hit_point);
|
|
}
|
|
return hit_point;
|
|
}
|
|
|
|
float HeroAgent::GetShotRange()
|
|
{
|
|
if (owner_->GetCurrWeapon()) {
|
|
return owner_->GetCurrWeapon()->meta->range();
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
void HeroAgent::SetV(int id, int val)
|
|
{
|
|
auto itr = dyn_hash_.find(id);
|
|
if (itr != dyn_hash_.end()) {
|
|
itr->second = val;
|
|
} else {
|
|
dyn_hash_[id] = val;
|
|
}
|
|
}
|
|
|
|
int HeroAgent::GetV(int id)
|
|
{
|
|
auto itr = dyn_hash_.find(id);
|
|
if (itr != dyn_hash_.end()) {
|
|
return itr->second;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int HeroAgent::IncV(int id, int val)
|
|
{
|
|
auto itr = dyn_hash_.find(id);
|
|
if (itr != dyn_hash_.end()) {
|
|
itr->second += val;
|
|
return itr->second;
|
|
} else {
|
|
dyn_hash_[id] = val;
|
|
return val;
|
|
}
|
|
}
|
|
|
|
int HeroAgent::DecV(int id, int val)
|
|
{
|
|
IncV(id, -val);
|
|
}
|
|
|
|
bool HeroAgent::HasBuffEffect(int effect_id)
|
|
{
|
|
return owner_->HasBuffEffect(effect_id);
|
|
}
|
|
|
|
bool HeroAgent::IsNearGas(float range)
|
|
{
|
|
abort();
|
|
return false;
|
|
}
|
|
|
|
bool HeroAgent::MasterInRange(float range)
|
|
{
|
|
abort();
|
|
return false;
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::SearchEnemy(float range)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoIdle(int min_val, int max_val)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoMoveCurrentTargetRaycast()
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoShotCurrentTargetRaycast()
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoMoveMasterRaycast()
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoFindPath(const glm::vec3& pos)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoFindPathEx(const glm::vec3& pos, float distance)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoStartMove(float distance)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
behaviac::EBTStatus HeroAgent::CoSleep(int time)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
Room* HeroAgent::GetRoom()
|
|
{
|
|
return owner_->room;
|
|
}
|
|
|
|
bool HeroAgent::HasFlag(int tag)
|
|
{
|
|
return a8::HasBitFlag(flags_, tag);
|
|
}
|
|
|
|
void HeroAgent::SetFlag(int tag)
|
|
{
|
|
a8::SetBitFlag(flags_, tag);
|
|
}
|
|
|
|
void HeroAgent::UnSetFlag(int tag)
|
|
{
|
|
a8::UnSetBitFlag(flags_, tag);
|
|
}
|