1
This commit is contained in:
commit
18de7c6deb
@ -17,8 +17,17 @@ void AIComponent::SetAiLevel(int ai_level)
|
|||||||
ai_level_ = ai_level;
|
ai_level_ = ai_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AIComponent::SetAiMode(int ai_mode)
|
||||||
|
{
|
||||||
|
ai_mode_ = ai_mode;
|
||||||
|
}
|
||||||
|
|
||||||
int AIComponent::GetAiLevel()
|
int AIComponent::GetAiLevel()
|
||||||
{
|
{
|
||||||
return ai_level_;
|
return ai_level_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AIComponent::GetAiMode()
|
||||||
|
{
|
||||||
|
return ai_mode_;
|
||||||
|
}
|
||||||
|
@ -9,10 +9,14 @@ class AIComponent
|
|||||||
virtual ~AIComponent();
|
virtual ~AIComponent();
|
||||||
virtual void Update(int delta_time);
|
virtual void Update(int delta_time);
|
||||||
virtual float GetAttackRate() { return 0;};
|
virtual float GetAttackRate() { return 0;};
|
||||||
|
virtual void Reset() {};
|
||||||
void SetAiLevel(int ai_level);
|
void SetAiLevel(int ai_level);
|
||||||
|
void SetAiMode(int ai_mode);
|
||||||
int GetAiLevel();
|
int GetAiLevel();
|
||||||
|
int GetAiMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int ai_level_ = 0;
|
int ai_level_ = 0;
|
||||||
|
int ai_mode_ = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -410,7 +410,7 @@ void AndroidNewAI::UpdateNewAI()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ai_meta && GetAiLevel() != 0) {
|
if (!ai_meta && GetAiLevel() != 0) {
|
||||||
ai_meta = MetaMgr::Instance()->GetAI(GetAiLevel());
|
ai_meta = MetaMgr::Instance()->GetAI(GetAiLevel(), 0);
|
||||||
if (!ai_meta) {
|
if (!ai_meta) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,12 @@
|
|||||||
#include "android.h"
|
#include "android.h"
|
||||||
#include "metamgr.h"
|
#include "metamgr.h"
|
||||||
#include "android.ai.h"
|
#include "android.ai.h"
|
||||||
#include "zombie.ai.h"
|
#include "zombiemode.ai.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
Android::Android():Human()
|
Android::Android():Human()
|
||||||
{
|
{
|
||||||
ai = new ZombieAI;
|
|
||||||
ai->owner = this;
|
|
||||||
#if 0
|
#if 0
|
||||||
++PerfMonitor::Instance()->entity_num[ET_Android];
|
++PerfMonitor::Instance()->entity_num[ET_Android];
|
||||||
#endif
|
#endif
|
||||||
@ -18,8 +16,9 @@ Android::Android():Human()
|
|||||||
|
|
||||||
Android::~Android()
|
Android::~Android()
|
||||||
{
|
{
|
||||||
delete ai;
|
if (ai) {
|
||||||
ai = nullptr;
|
A8_SAFE_DELETE(ai);
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
--PerfMonitor::Instance()->entity_num[ET_Android];
|
--PerfMonitor::Instance()->entity_num[ET_Android];
|
||||||
#endif
|
#endif
|
||||||
@ -27,6 +26,15 @@ Android::~Android()
|
|||||||
|
|
||||||
void Android::Initialize()
|
void Android::Initialize()
|
||||||
{
|
{
|
||||||
|
if (room->GetRoomMode() == kZombieMode) {
|
||||||
|
ai = new ZombieModeAI;
|
||||||
|
ai->owner = this;
|
||||||
|
ai->SetAiLevel(8);
|
||||||
|
ai->SetAiMode(kHumanAiMode);
|
||||||
|
} else {
|
||||||
|
ai = new AndroidNewAI;
|
||||||
|
ai->owner = this;
|
||||||
|
}
|
||||||
Human::Initialize();
|
Human::Initialize();
|
||||||
RandSkin();
|
RandSkin();
|
||||||
GiveEquip();
|
GiveEquip();
|
||||||
|
@ -131,6 +131,7 @@ enum BuffEffectType_e
|
|||||||
kBET_Pull = 12, //拉人(主动方)
|
kBET_Pull = 12, //拉人(主动方)
|
||||||
kBET_Terminator = 13, //终结者模式
|
kBET_Terminator = 13, //终结者模式
|
||||||
kBET_PlayShotAni = 14, //播放射击动画
|
kBET_PlayShotAni = 14, //播放射击动画
|
||||||
|
kBET_Vertigo = 15, //眩晕
|
||||||
kBET_End
|
kBET_End
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -303,6 +304,13 @@ enum RaceType_e
|
|||||||
kZombieRace = 2
|
kZombieRace = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum AIMode_e
|
||||||
|
{
|
||||||
|
kChiJiAiMode = 0,
|
||||||
|
kHumanAiMode = 1,
|
||||||
|
kZombieAiMode = 2
|
||||||
|
};
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
@ -357,3 +365,5 @@ const int HUMAN_RACE_META_START_ID = 5001;
|
|||||||
const int ZOMBIE_RACE_META_START_ID = 6001;
|
const int ZOMBIE_RACE_META_START_ID = 6001;
|
||||||
|
|
||||||
const int TERMINATOR_BUFF_ID = 1033;
|
const int TERMINATOR_BUFF_ID = 1033;
|
||||||
|
|
||||||
|
const int TURN_OVER_SKILL_ID = 41001;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "buff.h"
|
#include "buff.h"
|
||||||
#include "roomobstacle.h"
|
#include "roomobstacle.h"
|
||||||
|
#include "aicomponent.h"
|
||||||
|
|
||||||
#include "framework/cpp/utils.h"
|
#include "framework/cpp/utils.h"
|
||||||
#include "framework/cpp/httpclientpool.h"
|
#include "framework/cpp/httpclientpool.h"
|
||||||
@ -1924,6 +1925,15 @@ void Human::ChangeToRace(RaceType_e race, int level)
|
|||||||
race != kZombieRace) {
|
race != kZombieRace) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
if (race_ != race && IsAndroid()) {
|
||||||
|
Android* android = (Android*)this;
|
||||||
|
android->ai->Reset();
|
||||||
|
if (race == kHumanRace) {
|
||||||
|
android->ai->SetAiMode(kHumanAiMode);
|
||||||
|
} else if (race == kZombieRace) {
|
||||||
|
android->ai->SetAiMode(kZombieAiMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
race_ = race;
|
race_ = race;
|
||||||
level_ = level;
|
level_ = level;
|
||||||
if (race_ == kHumanRace) {
|
if (race_ == kHumanRace) {
|
||||||
|
@ -602,12 +602,7 @@ private:
|
|||||||
MetaData::AI& item = a8::FastAppend(ai_list);
|
MetaData::AI& item = a8::FastAppend(ai_list);
|
||||||
item.i = &meta;
|
item.i = &meta;
|
||||||
item.Init();
|
item.Init();
|
||||||
ai_hash[meta.ai_level()] = &item;
|
ai_hash[a8::MakeInt64(meta.ai_level(), meta.ai_mode())] = &item;
|
||||||
}
|
|
||||||
for (int i = 1; i <= MAX_AI_LEVEL; ++i) {
|
|
||||||
if (ai_hash.find(i) == ai_hash.end()) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,8 +831,8 @@ MetaData::Robot* MetaMgr::RandRobot(std::set<int>& refreshed_robot_set)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData::AI* MetaMgr::GetAI(int ai_level)
|
MetaData::AI* MetaMgr::GetAI(int ai_level, int ai_mode)
|
||||||
{
|
{
|
||||||
auto itr = loader_->ai_hash.find(ai_level);
|
auto itr = loader_->ai_hash.find(a8::MakeInt64(ai_level, ai_mode));
|
||||||
return itr != loader_->ai_hash.end() ? itr->second : nullptr;
|
return itr != loader_->ai_hash.end() ? itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
int GetKillPointParam1(int kill_num);
|
int GetKillPointParam1(int kill_num);
|
||||||
int GetKillPointParam2(int kill_num);
|
int GetKillPointParam2(int kill_num);
|
||||||
MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set);
|
MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set);
|
||||||
MetaData::AI* GetAI(int ai_level);
|
MetaData::AI* GetAI(int ai_level, int ai_mode);
|
||||||
|
|
||||||
int gas_inactive_time = 10;
|
int gas_inactive_time = 10;
|
||||||
int newbie_gas_inactive_time = 5;
|
int newbie_gas_inactive_time = 5;
|
||||||
|
@ -127,6 +127,9 @@ void Player::UpdateMove()
|
|||||||
SetLastCollisionDoor(nullptr);
|
SetLastCollisionDoor(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (HasBuffEffect(kBET_Vertigo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (HasBuffEffect(kBET_Camouflage)) {
|
if (HasBuffEffect(kBET_Camouflage)) {
|
||||||
RemoveBuffByEffectId(kBET_Camouflage);
|
RemoveBuffByEffectId(kBET_Camouflage);
|
||||||
}
|
}
|
||||||
@ -163,6 +166,9 @@ void Player::UpdateShot()
|
|||||||
series_shot_frames = 0;
|
series_shot_frames = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (HasBuffEffect(kBET_Vertigo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (shot_start) {
|
if (shot_start) {
|
||||||
shot_start = false;
|
shot_start = false;
|
||||||
Shot();
|
Shot();
|
||||||
@ -317,6 +323,9 @@ void Player::UpdateGetDown()
|
|||||||
|
|
||||||
void Player::UpdateUseSkill()
|
void Player::UpdateUseSkill()
|
||||||
{
|
{
|
||||||
|
if (HasBuffEffect(kBET_Vertigo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
DoSkill();
|
DoSkill();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +561,10 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
weapon->ammo = 0;
|
weapon->ammo = 0;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
AutoLoadingBullet();
|
if (room->GetRoomMode() == kZombieMode && HasBuffEffect(kBET_Car)) {
|
||||||
|
} else {
|
||||||
|
AutoLoadingBullet();
|
||||||
|
}
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "entityfactory.h"
|
#include "entityfactory.h"
|
||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
|
#include "framework/cpp/utils.h"
|
||||||
|
|
||||||
const size_t NORMAL_ROOM_MAX_PLAYER_NUM = 40;
|
const size_t NORMAL_ROOM_MAX_PLAYER_NUM = 40;
|
||||||
const size_t MINI_ROOM_MAX_PLAYER_NUM = 20;
|
const size_t MINI_ROOM_MAX_PLAYER_NUM = 20;
|
||||||
|
|
||||||
@ -1983,7 +1985,11 @@ long long Room::GetGasInactiveTime()
|
|||||||
{
|
{
|
||||||
if (room_mode_ == kZombieMode) {
|
if (room_mode_ == kZombieMode) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
return 5;
|
if (f8::IsTestEnv()) {
|
||||||
|
return MetaMgr::Instance()->zbmode_gas_inactive_time + 10000;
|
||||||
|
} else {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return MetaMgr::Instance()->zbmode_gas_inactive_time;
|
return MetaMgr::Instance()->zbmode_gas_inactive_time;
|
||||||
#endif
|
#endif
|
||||||
@ -2655,8 +2661,8 @@ void Room::AddPlayerPostProc(Player* hum)
|
|||||||
RandRemoveAndroid();
|
RandRemoveAndroid();
|
||||||
}
|
}
|
||||||
if (GetRoomMode() == kZombieMode) {
|
if (GetRoomMode() == kZombieMode) {
|
||||||
#if 0
|
#if 1
|
||||||
hum->ChangeToRace(kZombieRace, 1);
|
hum->ChangeToRace(kZombieRace, 2);
|
||||||
#else
|
#else
|
||||||
hum->ChangeToRace(kHumanRace, 1);
|
hum->ChangeToRace(kHumanRace, 1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
#include "zombie.ai.h"
|
#include "zombiemode.ai.h"
|
||||||
#include "android.h"
|
#include "android.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "metamgr.h"
|
#include "metamgr.h"
|
||||||
@ -39,31 +39,17 @@ public:
|
|||||||
MetaData::AI* ai_meta = nullptr;
|
MetaData::AI* ai_meta = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
ZombieModeAI::ZombieModeAI()
|
||||||
nn目标:ai可切换,降级/升级(根据系统当前负载)
|
|
||||||
|
|
||||||
ai级别
|
|
||||||
1: 木桩(不射击)
|
|
||||||
2: 站桩间隔开枪
|
|
||||||
3: 站桩描边射击
|
|
||||||
4: 站桩扫射(连续射击)
|
|
||||||
5: 跑动间隔开枪
|
|
||||||
6: 跑动描边射击
|
|
||||||
7: 跑动扫射
|
|
||||||
8: 跑动射击
|
|
||||||
*/
|
|
||||||
|
|
||||||
ZombieAI::ZombieAI()
|
|
||||||
{
|
{
|
||||||
node_ = new ZombieAINode();
|
node_ = new ZombieAINode();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZombieAI::~ZombieAI()
|
ZombieModeAI::~ZombieModeAI()
|
||||||
{
|
{
|
||||||
A8_SAFE_DELETE(node_);
|
A8_SAFE_DELETE(node_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::Update(int delta_time)
|
void ZombieModeAI::Update(int delta_time)
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
if (hum->poisoning) {
|
if (hum->poisoning) {
|
||||||
@ -75,13 +61,17 @@ void ZombieAI::Update(int delta_time)
|
|||||||
if (hum->dead) {
|
if (hum->dead) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hum->room->GetGasData().gas_mode == GasInactive) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UpdateAI();
|
UpdateAI();
|
||||||
}
|
}
|
||||||
|
|
||||||
float ZombieAI::GetAttackRate()
|
void ZombieModeAI::Reset()
|
||||||
|
{
|
||||||
|
ChangeToState(ZSE_Idle);
|
||||||
|
node_->param1 = 2;
|
||||||
|
node_->ai_meta = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ZombieModeAI::GetAttackRate()
|
||||||
{
|
{
|
||||||
if (!node_->ai_meta) {
|
if (!node_->ai_meta) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -90,14 +80,14 @@ float ZombieAI::GetAttackRate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::UpdateAI()
|
void ZombieModeAI::UpdateAI()
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
if (a8::HasBitFlag(hum->status, HS_Disable)) {
|
if (a8::HasBitFlag(hum->status, HS_Disable)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!node_->ai_meta && GetAiLevel() != 0) {
|
if (!node_->ai_meta && GetAiLevel() != 0) {
|
||||||
node_->ai_meta = MetaMgr::Instance()->GetAI(GetAiLevel());
|
node_->ai_meta = MetaMgr::Instance()->GetAI(GetAiLevel(), GetAiMode());
|
||||||
if (!node_->ai_meta) {
|
if (!node_->ai_meta) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -145,7 +135,7 @@ void ZombieAI::UpdateAI()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::UpdateIdle()
|
void ZombieModeAI::UpdateIdle()
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
if (hum->room->GetFrameNo() > node_->frameno + node_->param1) {
|
if (hum->room->GetFrameNo() > node_->frameno + node_->param1) {
|
||||||
@ -153,7 +143,7 @@ void ZombieAI::UpdateIdle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::UpdateThinking()
|
void ZombieModeAI::UpdateThinking()
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
if (hum->room->GetGasData().gas_mode == GasInactive ||
|
if (hum->room->GetGasData().gas_mode == GasInactive ||
|
||||||
@ -183,9 +173,12 @@ void ZombieAI::UpdateThinking()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::UpdateAttack()
|
void ZombieModeAI::UpdateAttack()
|
||||||
{
|
{
|
||||||
Human* myself = (Human*)owner;
|
Human* myself = (Human*)owner;
|
||||||
|
if (myself->HasBuffEffect(kBET_Vertigo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!node_->target || node_->target->dead) {
|
if (!node_->target || node_->target->dead) {
|
||||||
ChangeToState(ZSE_Thinking);
|
ChangeToState(ZSE_Thinking);
|
||||||
return;
|
return;
|
||||||
@ -196,7 +189,11 @@ void ZombieAI::UpdateAttack()
|
|||||||
}
|
}
|
||||||
float distance = myself->GetPos().Distance(node_->target->GetPos());
|
float distance = myself->GetPos().Distance(node_->target->GetPos());
|
||||||
if (distance > GetAttackRange()) {
|
if (distance > GetAttackRange()) {
|
||||||
if (node_->ai_meta->i->pursuit_radius() <= 0) {
|
if (myself->CanUseSkill() &&
|
||||||
|
myself->CurrentSkillMeta()->i->skill_id() != TURN_OVER_SKILL_ID &&
|
||||||
|
distance < myself->CurrentSkillMeta()->i->skill_distance()) {
|
||||||
|
DoSkill();
|
||||||
|
} else if (node_->ai_meta->i->pursuit_radius() <= 0) {
|
||||||
//站桩
|
//站桩
|
||||||
ChangeToState(ZSE_Thinking);
|
ChangeToState(ZSE_Thinking);
|
||||||
} else {
|
} else {
|
||||||
@ -245,7 +242,7 @@ void ZombieAI::UpdateAttack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::UpdateRandomWalk()
|
void ZombieModeAI::UpdateRandomWalk()
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
if (hum->room->GetFrameNo() > node_->frameno + node_->param1) {
|
if (hum->room->GetFrameNo() > node_->frameno + node_->param1) {
|
||||||
@ -253,7 +250,7 @@ void ZombieAI::UpdateRandomWalk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::UpdatePursuit()
|
void ZombieModeAI::UpdatePursuit()
|
||||||
{
|
{
|
||||||
Human* myself = (Human*)owner;
|
Human* myself = (Human*)owner;
|
||||||
float distance = myself->GetPos().Distance(node_->target->GetPos());
|
float distance = myself->GetPos().Distance(node_->target->GetPos());
|
||||||
@ -266,9 +263,12 @@ void ZombieAI::UpdatePursuit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::DoMove()
|
void ZombieModeAI::DoMove()
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
|
if (hum->HasBuffEffect(kBET_Vertigo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (std::abs(hum->move_dir.x) > FLT_EPSILON ||
|
if (std::abs(hum->move_dir.x) > FLT_EPSILON ||
|
||||||
std::abs(hum->move_dir.y) > FLT_EPSILON) {
|
std::abs(hum->move_dir.y) > FLT_EPSILON) {
|
||||||
hum->on_move_collision =
|
hum->on_move_collision =
|
||||||
@ -290,7 +290,7 @@ void ZombieAI::DoMove()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::ChangeToState(ZombieState_e to_state)
|
void ZombieModeAI::ChangeToState(ZombieState_e to_state)
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
switch (to_state) {
|
switch (to_state) {
|
||||||
@ -361,7 +361,7 @@ void ZombieAI::ChangeToState(ZombieState_e to_state)
|
|||||||
node_->exec_frame_num = 0;
|
node_->exec_frame_num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Human* ZombieAI::GetTarget()
|
Human* ZombieModeAI::GetTarget()
|
||||||
{
|
{
|
||||||
if (GetAiLevel() <= 1) {
|
if (GetAiLevel() <= 1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -401,8 +401,7 @@ Human* ZombieAI::GetTarget()
|
|||||||
node_->nearest_human = target;
|
node_->nearest_human = target;
|
||||||
node_->last_check_nearest_human_frameno = myself->room->GetFrameNo();
|
node_->last_check_nearest_human_frameno = myself->room->GetFrameNo();
|
||||||
float distance = myself->GetPos().Distance(target->GetPos());
|
float distance = myself->GetPos().Distance(target->GetPos());
|
||||||
#if 1
|
#if 0
|
||||||
#else
|
|
||||||
if (distance > GetAttackRange()) {
|
if (distance > GetAttackRange()) {
|
||||||
target = nullptr;
|
target = nullptr;
|
||||||
}
|
}
|
||||||
@ -411,7 +410,7 @@ Human* ZombieAI::GetTarget()
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ZombieAI::GetAttackRange()
|
float ZombieModeAI::GetAttackRange()
|
||||||
{
|
{
|
||||||
float attack_range = 0;
|
float attack_range = 0;
|
||||||
Human* myself = (Human*)owner;
|
Human* myself = (Human*)owner;
|
||||||
@ -424,7 +423,7 @@ float ZombieAI::GetAttackRange()
|
|||||||
return attack_range;
|
return attack_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZombieAI::DoShot()
|
void ZombieModeAI::DoShot()
|
||||||
{
|
{
|
||||||
Human* myself = (Human*)owner;
|
Human* myself = (Human*)owner;
|
||||||
if (!node_->target) {
|
if (!node_->target) {
|
||||||
@ -464,7 +463,15 @@ void ZombieAI::DoShot()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZombieAI::GetAttackTimes()
|
void ZombieModeAI::DoSkill()
|
||||||
|
{
|
||||||
|
Human* myself = (Human*)owner;
|
||||||
|
myself->skill_target_id = node_->target->GetEntityUniId();
|
||||||
|
myself->skill_target_pos = node_->target->GetPos();
|
||||||
|
myself->DoSkill();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZombieModeAI::GetAttackTimes()
|
||||||
{
|
{
|
||||||
Human* myself = (Human*)owner;
|
Human* myself = (Human*)owner;
|
||||||
if (myself->curr_weapon) {
|
if (myself->curr_weapon) {
|
@ -13,13 +13,14 @@ enum ZombieState_e
|
|||||||
|
|
||||||
class Human;
|
class Human;
|
||||||
class ZombieAINode;
|
class ZombieAINode;
|
||||||
class ZombieAI : public AIComponent
|
class ZombieModeAI : public AIComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ZombieAI();
|
ZombieModeAI();
|
||||||
virtual ~ZombieAI() override;
|
virtual ~ZombieModeAI() override;
|
||||||
virtual void Update(int delta_time) override;
|
virtual void Update(int delta_time) override;
|
||||||
|
virtual void Reset() override;
|
||||||
float GetAttackRate();
|
float GetAttackRate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -32,6 +33,7 @@ private:
|
|||||||
void DoMove();
|
void DoMove();
|
||||||
void ChangeToState(ZombieState_e to_state);
|
void ChangeToState(ZombieState_e to_state);
|
||||||
void DoShot();
|
void DoShot();
|
||||||
|
void DoSkill();
|
||||||
|
|
||||||
Human* GetTarget();
|
Human* GetTarget();
|
||||||
float GetAttackRange();
|
float GetAttackRange();
|
@ -263,6 +263,7 @@ message AI
|
|||||||
optional string random_move_time = 9;
|
optional string random_move_time = 9;
|
||||||
optional int32 attack_range = 10;
|
optional int32 attack_range = 10;
|
||||||
optional float attack_rate = 11;
|
optional float attack_rate = 11;
|
||||||
|
optional int32 ai_mode = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
//end
|
//end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user