1
This commit is contained in:
parent
58cdec580c
commit
d84652ec93
@ -14,11 +14,14 @@ void AndroidAI::Update(int delta_time)
|
|||||||
hum->poisoning_time += delta_time;
|
hum->poisoning_time += delta_time;
|
||||||
}
|
}
|
||||||
state_elapsed_time += delta_time;
|
state_elapsed_time += delta_time;
|
||||||
|
if (hum->dead) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (hum->poisoning) {
|
if (hum->poisoning) {
|
||||||
hum->UpdatePoisoning();
|
hum->UpdatePoisoning();
|
||||||
}
|
}
|
||||||
if (hum->dead) {
|
if (hum->playing_skill) {
|
||||||
return;
|
hum->UpdateSkill();
|
||||||
}
|
}
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AS_thinking:
|
case AS_thinking:
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "android.h"
|
#include "android.h"
|
||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
|
#include "obstacle.h"
|
||||||
|
|
||||||
#include "framework/cpp/utils.h"
|
#include "framework/cpp/utils.h"
|
||||||
#include "framework/cpp/httpclientpool.h"
|
#include "framework/cpp/httpclientpool.h"
|
||||||
@ -431,6 +432,21 @@ void Human::UpdatePoisoning()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::UpdateSkill()
|
||||||
|
{
|
||||||
|
if (skill_meta) {
|
||||||
|
if (curr_skill_phase < skill_meta->phases.size()) {
|
||||||
|
MetaData::SkillPhase* phase = &skill_meta->phases[curr_skill_phase];
|
||||||
|
if (phase->time_offset > (room->frame_no - last_use_skill_frameno_) * FRAME_RATE_MS) {
|
||||||
|
ProcSkillPhase(phase);
|
||||||
|
++curr_skill_phase;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playing_skill = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Human::SyncAroundPlayers()
|
void Human::SyncAroundPlayers()
|
||||||
{
|
{
|
||||||
for (auto& cell : grid_list) {
|
for (auto& cell : grid_list) {
|
||||||
@ -647,18 +663,28 @@ bool Human::HasNoDownedTeammate()
|
|||||||
void Human::DoSkill()
|
void Human::DoSkill()
|
||||||
{
|
{
|
||||||
if (skill_meta && GetSkillLeftTime() <= 0) {
|
if (skill_meta && GetSkillLeftTime() <= 0) {
|
||||||
|
use_skill = false;
|
||||||
|
curr_skill_phase = 0;
|
||||||
|
skill_dir = a8::Vec2();
|
||||||
|
skill_target_pos = a8::Vec2();
|
||||||
|
skill_param1 = 0.0f;
|
||||||
|
playing_skill = true;
|
||||||
|
last_use_skill_frameno_ = room->frame_no;
|
||||||
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
||||||
if (entity && entity->entity_type == ET_Player) {
|
if (entity && entity->entity_type == ET_Player) {
|
||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
std::set<Entity*> target_list;
|
std::set<Entity*> target_list;
|
||||||
|
skill_target_pos = hum->pos;
|
||||||
SelectSkillTargets(hum->pos, target_list);
|
SelectSkillTargets(hum->pos, target_list);
|
||||||
TriggerBuff(target_list, BTT_UseSkill);
|
TriggerBuff(target_list, BTT_UseSkill);
|
||||||
|
if (!skill_meta->phases.empty() && skill_meta->phases[0].time_offset <= 0) {
|
||||||
|
UpdateSkill();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playing_skill = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use_skill = false;
|
use_skill = false;
|
||||||
skill_target_id = 0;
|
|
||||||
skill_dir = a8::Vec2();
|
|
||||||
skill_param1 = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::FindLocation()
|
void Human::FindLocation()
|
||||||
@ -1568,6 +1594,11 @@ void Human::Revive()
|
|||||||
room->frame_event.AddRevive(this);
|
room->frame_event.AddRevive(this);
|
||||||
room->OnHumanRevive(this);
|
room->OnHumanRevive(this);
|
||||||
|
|
||||||
|
use_skill = false;
|
||||||
|
curr_skill_phase = 0;
|
||||||
|
skill_dir = a8::Vec2();
|
||||||
|
skill_param1 = 0.0f;
|
||||||
|
playing_skill = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list)
|
void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list)
|
||||||
@ -1677,3 +1708,29 @@ Buff* Human::GetBuffByEffectId(int effect_id)
|
|||||||
{
|
{
|
||||||
return IsValidBuffEffect(effect_id) ? buff_effect_[effect_id] : nullptr;
|
return IsValidBuffEffect(effect_id) ? buff_effect_[effect_id] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
|
||||||
|
{
|
||||||
|
switch (phase->func_id) {
|
||||||
|
case Skill_Jump:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Skill_Shot:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Skill_SummonObject:
|
||||||
|
{
|
||||||
|
Obstacle* obstacle = room->CreateObstacle(phase->param1.GetInt(), pos.x, pos.y);
|
||||||
|
if (obstacle) {
|
||||||
|
obstacle->master_id = entity_uniid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ namespace MetaData
|
|||||||
struct Dress;
|
struct Dress;
|
||||||
struct Skill;
|
struct Skill;
|
||||||
struct Tank;
|
struct Tank;
|
||||||
|
struct SkillPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HumanStatus
|
enum HumanStatus
|
||||||
@ -121,7 +122,9 @@ class Human : public Entity
|
|||||||
int curr_skill_phase = 0;
|
int curr_skill_phase = 0;
|
||||||
int skill_target_id = 0;
|
int skill_target_id = 0;
|
||||||
a8::Vec2 skill_dir;
|
a8::Vec2 skill_dir;
|
||||||
|
a8::Vec2 skill_target_pos;
|
||||||
float skill_param1 = 0;
|
float skill_param1 = 0;
|
||||||
|
bool playing_skill = false;
|
||||||
|
|
||||||
Human();
|
Human();
|
||||||
virtual ~Human() override;
|
virtual ~Human() override;
|
||||||
@ -142,6 +145,7 @@ class Human : public Entity
|
|||||||
float GetRadius();
|
float GetRadius();
|
||||||
float GetMaxHP();
|
float GetMaxHP();
|
||||||
void UpdatePoisoning();
|
void UpdatePoisoning();
|
||||||
|
void UpdateSkill();
|
||||||
void SyncAroundPlayers();
|
void SyncAroundPlayers();
|
||||||
void AutoLoadingBullet(bool manual = false);
|
void AutoLoadingBullet(bool manual = false);
|
||||||
void StartAction(ActionType_e action_type,
|
void StartAction(ActionType_e action_type,
|
||||||
@ -218,6 +222,7 @@ private:
|
|||||||
void Revive();
|
void Revive();
|
||||||
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
|
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
|
||||||
Buff* GetBuffById(int buff_id);
|
Buff* GetBuffById(int buff_id);
|
||||||
|
void ProcSkillPhase(MetaData::SkillPhase* phase);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long long last_shot_frameno_ = 0;
|
long long last_shot_frameno_ = 0;
|
||||||
|
@ -114,6 +114,9 @@ void Obstacle::FillMFObjectFull(cs::MFObjectFull* full_data)
|
|||||||
p->set_health(health);
|
p->set_health(health);
|
||||||
p->set_dead(dead);
|
p->set_dead(dead);
|
||||||
p->set_dead_at_thisframe(dead ? dead_frameno <= room->frame_no : false);
|
p->set_dead_at_thisframe(dead ? dead_frameno <= room->frame_no : false);
|
||||||
|
if (master_id != 0) {
|
||||||
|
p->set_master_id(master_id);
|
||||||
|
}
|
||||||
|
|
||||||
p->set_is_door(is_door);
|
p->set_is_door(is_door);
|
||||||
if (is_door) {
|
if (is_door) {
|
||||||
|
@ -32,6 +32,7 @@ class Obstacle : public Entity
|
|||||||
DoorState_e door_state = DoorStateClose;
|
DoorState_e door_state = DoorStateClose;
|
||||||
Building* building = nullptr;
|
Building* building = nullptr;
|
||||||
int door_house_uniid = 0;
|
int door_house_uniid = 0;
|
||||||
|
int master_id = 0;
|
||||||
const metatable::DoorObjJson* door_state0 = nullptr;
|
const metatable::DoorObjJson* door_state0 = nullptr;
|
||||||
const metatable::DoorObjJson* door_state1 = nullptr;
|
const metatable::DoorObjJson* door_state1 = nullptr;
|
||||||
|
|
||||||
|
@ -64,6 +64,9 @@ void Player::Update(int delta_time)
|
|||||||
if (poisoning) {
|
if (poisoning) {
|
||||||
UpdatePoisoning();
|
UpdatePoisoning();
|
||||||
}
|
}
|
||||||
|
if (playing_skill) {
|
||||||
|
UpdateSkill();
|
||||||
|
}
|
||||||
if (select_weapon) {
|
if (select_weapon) {
|
||||||
UpdateSelectWeapon();
|
UpdateSelectWeapon();
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ public:
|
|||||||
std::set<Human*>* GetAliveTeam();
|
std::set<Human*>* GetAliveTeam();
|
||||||
bool CanJoin(const std::string& accountid);
|
bool CanJoin(const std::string& accountid);
|
||||||
void OnPlayerOffline(Player* hum);
|
void OnPlayerOffline(Player* hum);
|
||||||
|
Obstacle* CreateObstacle(int id, float x, float y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
@ -98,7 +99,6 @@ private:
|
|||||||
void AutoMatchTeam();
|
void AutoMatchTeam();
|
||||||
void MatchTeam(Human* hum);
|
void MatchTeam(Human* hum);
|
||||||
int NewTeam();
|
int NewTeam();
|
||||||
Obstacle* CreateObstacle(int id, float x, float y);
|
|
||||||
void CreateThings();
|
void CreateThings();
|
||||||
void CreateBuilding(int thing_id, float building_x, float building_y);
|
void CreateBuilding(int thing_id, float building_x, float building_y);
|
||||||
Obstacle* InternalCreateObstacle(int id, float x, float y,
|
Obstacle* InternalCreateObstacle(int id, float x, float y,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user