95 lines
1.8 KiB
C++
95 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "aicomponent.h"
|
|
|
|
enum AndroidState_e
|
|
{
|
|
AS_thinking,
|
|
AS_moving,
|
|
AS_attack
|
|
};
|
|
|
|
enum AndroidStateEx_e
|
|
{
|
|
ASE_Idle = 0,
|
|
ASE_Thinking = 1,
|
|
ASE_Attack = 2,
|
|
ASE_RandomWalk = 3,
|
|
ASE_Pursuit = 4
|
|
};
|
|
|
|
class Human;
|
|
class AINode
|
|
{
|
|
public:
|
|
AndroidStateEx_e main_state = ASE_Idle;
|
|
long long frameno = 0;
|
|
long long exec_frame_num = 0;
|
|
long long start_shot_frameno = 0;
|
|
long long next_random_move_frameno = 0;
|
|
int shot_times = 0;
|
|
int total_shot_times = 0;
|
|
int next_total_shot_times = 0;
|
|
|
|
long long param1 = 0;
|
|
Human* target = nullptr;
|
|
Human* nearest_human = nullptr;
|
|
long long last_check_nearest_human_frameno = 0;
|
|
a8::Vec2 shot_dir;
|
|
};
|
|
|
|
struct OldAiData
|
|
{
|
|
AndroidState_e state = AS_thinking;
|
|
int state_elapsed_time = 0;
|
|
Human* last_target = nullptr;
|
|
long long last_attack_frameno = 0;
|
|
long long last_findenemy_frameno = 0;
|
|
long long series_attack_frames = 0;
|
|
};
|
|
|
|
namespace MetaData
|
|
{
|
|
class AI;
|
|
}
|
|
|
|
class Human;
|
|
class AndroidNewAI : public AIComponent
|
|
{
|
|
public:
|
|
|
|
virtual ~AndroidNewAI() override;
|
|
virtual void Update(int delta_time) override;
|
|
float GetAttackRate();
|
|
|
|
private:
|
|
void DefaultAi();
|
|
void ChangeToStateOldAI(AndroidState_e to_state);
|
|
void DoMoveOldAI();
|
|
void DoAttackOldAI();
|
|
void UpdateNewBieNpc();
|
|
void UpdateLastNpc();
|
|
void UpdateNewBieRoomLogic();
|
|
|
|
void UpdateNewAI();
|
|
void UpdateIdle();
|
|
void UpdateThinking();
|
|
void UpdateAttack();
|
|
void UpdateRandomWalk();
|
|
void UpdatePursuit();
|
|
void DoMoveNewAI();
|
|
void ChangeToStateNewAI(AndroidStateEx_e to_state);
|
|
void DoShotNewAI();
|
|
|
|
Human* GetTarget();
|
|
float GetAttackRange();
|
|
int GetAttackTimes();
|
|
|
|
private:
|
|
OldAiData old_ai_data_;
|
|
|
|
MetaData::AI* ai_meta = nullptr;
|
|
AINode node_;
|
|
bool moving_ = false;
|
|
};
|