1
This commit is contained in:
parent
c81d94cf38
commit
8776b6f008
@ -93,14 +93,18 @@ void FrameEvent::AddBullet(int bullet_uniid,
|
||||
int trace_target_id,
|
||||
int hand,
|
||||
std::shared_ptr<std::set<int>> reporter_list,
|
||||
int shot_uniid)
|
||||
int shot_uniid,
|
||||
int force_player_id)
|
||||
{
|
||||
{
|
||||
auto& tuple = a8::FastAppend(room->frame_event_data->bullets_);
|
||||
std::get<0>(tuple) = sender;
|
||||
auto& p = std::get<1>(tuple);
|
||||
|
||||
p.set_player_id(sender.Get()->GetUniId());
|
||||
if (force_player_id) {
|
||||
} else {
|
||||
p.set_player_id(sender.Get()->GetUniId());
|
||||
}
|
||||
p.set_bullet_uniid(bullet_uniid);
|
||||
p.set_bullet_id(weapon_meta->use_bullet());
|
||||
TypeConvert::ToPb(born_pos, p.mutable_pos());
|
||||
|
@ -27,7 +27,8 @@ public:
|
||||
int trace_target_id,
|
||||
int hand,
|
||||
std::shared_ptr<std::set<int>> reporter_list,
|
||||
int shot_uniid);
|
||||
int shot_uniid,
|
||||
int force_player_id = 0);
|
||||
void RemoveBullet(glm::vec3 pos, int bullet_uniid);
|
||||
void AddExplosion(Bullet* bullet, int item_id, Position bomb_pos);
|
||||
void AddPlaySkill(CreatureWeakPtr& sender, int skill_id);
|
||||
|
@ -376,7 +376,6 @@ void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
||||
(revive_time * SERVER_FRAME_RATE,
|
||||
[room = room, hero_meta = GetHeroMeta(), pos = src_pos] (int event, const a8::Args* args)
|
||||
{
|
||||
glm::vec3 pos;
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
Hero* hero = room->CreateHero
|
||||
(nullptr,
|
||||
|
@ -430,6 +430,46 @@ behaviac::EBTStatus HeroAgent::SearchEnemy(float range)
|
||||
return behaviac::BT_FAILURE;
|
||||
}
|
||||
|
||||
behaviac::EBTStatus HeroAgent::SearchHumanEnemy(float range)
|
||||
{
|
||||
Creature* myself = owner_;
|
||||
Creature* target = nullptr;
|
||||
float last_distance = range + 1;
|
||||
owner_->room->grid_service->TraverseCreatures
|
||||
(owner_->room->GetRoomIdx(),
|
||||
owner_->GetGridList(),
|
||||
[myself, &last_distance, &target, range] (Creature* c, bool& stop)
|
||||
{
|
||||
if (!c->dead &&
|
||||
c->IsHuman() &&
|
||||
!a8::HasBitFlag(c->status, CS_Disable) &&
|
||||
!c->HasBuffEffect(kBET_Hide) &&
|
||||
!c->HasBuffEffect(kBET_Dive) &&
|
||||
!c->HasBuffEffect(kBET_Invincible) &&
|
||||
c->team_id != myself->team_id &&
|
||||
!c->IsCar() &&
|
||||
!myself->IsIgnoreTarget(c->GetUniId())) {
|
||||
if (a8::HasBitFlag(myself->status, CS_DisableAttackAndroid) &&
|
||||
c->IsAndroid()) {
|
||||
} else {
|
||||
float distance = c->GetPos().Distance2D2(myself->GetPos());
|
||||
if (distance <= range) {
|
||||
if (distance < last_distance) {
|
||||
target = c;
|
||||
last_distance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (target) {
|
||||
current_target_agent->SetTarget(target);
|
||||
return behaviac::BT_SUCCESS;
|
||||
}
|
||||
return behaviac::BT_FAILURE;
|
||||
}
|
||||
|
||||
void HeroAgent::SetBulletAngleOffset(int min_val, int max_val)
|
||||
{
|
||||
bullet_angle_offset_min_ = min_val;
|
||||
@ -1199,7 +1239,7 @@ behaviac::EBTStatus HeroAgent::CoGetNextMobaModeRoadPoint()
|
||||
out_point0 = std::get<0>(road.at(owner_->point_idx))->pos;
|
||||
out_point0 += dir * (float)a8::RandEx(0, 100);
|
||||
}
|
||||
if (owner_->GetPos().Distance2D2(out_point0) > 500) {
|
||||
if (owner_->GetPos().Distance2D2(out_point0) > 800) {
|
||||
std::vector<std::tuple<std::shared_ptr<mt::WorldObject>, int, int>> paths;
|
||||
int r = 0;
|
||||
for (auto& road : GetRoom()->GetMapMeta()->moba_path_points) {
|
||||
@ -1208,7 +1248,7 @@ behaviac::EBTStatus HeroAgent::CoGetNextMobaModeRoadPoint()
|
||||
for (auto itr = road.rbegin(); itr != road.rend(); ++itr) {
|
||||
auto& point = std::get<0>(*itr);
|
||||
if (point->pos.x < owner_->GetPos().GetX()) {
|
||||
if (owner_->GetPos().Distance2D2(point->pos) < 500) {
|
||||
if (owner_->GetPos().Distance2D2(point->pos) < 800) {
|
||||
paths.push_back(std::make_tuple
|
||||
(
|
||||
point,
|
||||
@ -1225,7 +1265,7 @@ behaviac::EBTStatus HeroAgent::CoGetNextMobaModeRoadPoint()
|
||||
for (auto itr = road.begin(); itr != road.end(); ++itr) {
|
||||
auto& point = std::get<0>(*itr);
|
||||
if (point->pos.x > owner_->GetPos().GetX()) {
|
||||
if (owner_->GetPos().Distance2D2(point->pos) < 500) {
|
||||
if (owner_->GetPos().Distance2D2(point->pos) < 800) {
|
||||
paths.push_back(std::make_tuple
|
||||
(
|
||||
point,
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
behaviac::EBTStatus RegisterEvents(behaviac::vector<BtEvent_e> events);
|
||||
behaviac::EBTStatus ClearEvents();
|
||||
behaviac::EBTStatus SearchEnemy(float range);
|
||||
behaviac::EBTStatus SearchHumanEnemy(float range);
|
||||
behaviac::EBTStatus TrySearchEnemy(float range, int min_interval, int max_interval);
|
||||
behaviac::EBTStatus DebugOut(std::string msg, int arg0, int arg1, int arg2);
|
||||
behaviac::EBTStatus RandomSafeZonePoint(int try_count, int step_len);
|
||||
|
@ -10,22 +10,56 @@ namespace mt
|
||||
|
||||
void MobaRoom::Init1()
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(towers(), strings, '|');
|
||||
if (strings.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
for (auto& str : strings) {
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
if (strings2.size() != 4) {
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(towers(), strings, '|');
|
||||
if (strings.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
glm::vec3 center = glm::vec3((float)a8::XValue(strings2[0]).GetDouble(),
|
||||
(float)a8::XValue(strings2[1]).GetDouble(),
|
||||
(float)a8::XValue(strings2[2]).GetDouble());
|
||||
float radius = (float)a8::XValue(strings2[3]).GetDouble();
|
||||
moba_towers.push_back(std::make_tuple(center, radius));
|
||||
for (auto& str : strings) {
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
if (strings2.size() != 4) {
|
||||
abort();
|
||||
}
|
||||
glm::vec3 center = glm::vec3((float)a8::XValue(strings2[0]).GetDouble(),
|
||||
(float)a8::XValue(strings2[1]).GetDouble(),
|
||||
(float)a8::XValue(strings2[2]).GetDouble());
|
||||
float radius = (float)a8::XValue(strings2[3]).GetDouble();
|
||||
moba_towers.push_back(std::make_tuple(center, radius));
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(monster_revive(), strings, '|');
|
||||
for (auto& str : strings) {
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
if (strings2.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
monster_revive_[a8::XValue(strings2[0])] = a8::XValue(strings2[1]).GetInt();
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(batterys(), strings, '|');
|
||||
if (strings.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
for (auto& str : strings) {
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
if (strings2.size() != 5) {
|
||||
abort();
|
||||
}
|
||||
glm::vec3 center = glm::vec3((float)a8::XValue(strings2[0]).GetDouble(),
|
||||
(float)a8::XValue(strings2[1]).GetDouble(),
|
||||
(float)a8::XValue(strings2[2]).GetDouble());
|
||||
float radius = (float)a8::XValue(strings2[3]).GetDouble();
|
||||
int equip_id = a8::XValue(strings2[4]);
|
||||
moba_batterys.push_back(std::make_tuple(center, radius, equip_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace mt
|
||||
void Init2();
|
||||
|
||||
std::vector<std::tuple<glm::vec3, float>> moba_towers;
|
||||
std::vector<std::tuple<glm::vec3, float, int>> moba_batterys;
|
||||
int GetMonsterReviveTime(int hero_id) const;
|
||||
|
||||
private:
|
||||
|
@ -17,6 +17,7 @@ namespace mtb
|
||||
float tower_recover_hp_rate() const { return tower_recover_hp_rate_; };
|
||||
const std::string towers() const { return towers_; };
|
||||
const std::string monster_revive() const { return monster_revive_; };
|
||||
const std::string batterys() const { return batterys_; };
|
||||
|
||||
bool has_map_id() const { return __flags__.test(0);};
|
||||
bool has_revive_time() const { return __flags__.test(1);};
|
||||
@ -25,6 +26,7 @@ namespace mtb
|
||||
bool has_tower_recover_hp_rate() const { return __flags__.test(4);};
|
||||
bool has_towers() const { return __flags__.test(5);};
|
||||
bool has_monster_revive() const { return __flags__.test(6);};
|
||||
bool has_batterys() const { return __flags__.test(7);};
|
||||
|
||||
protected:
|
||||
|
||||
@ -35,9 +37,10 @@ namespace mtb
|
||||
float tower_recover_hp_rate_ = 0.0f;
|
||||
std::string towers_;
|
||||
std::string monster_revive_;
|
||||
std::string batterys_;
|
||||
|
||||
public:
|
||||
std::bitset<7> __flags__;
|
||||
std::bitset<8> __flags__;
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -115,7 +115,7 @@ namespace mtb
|
||||
{
|
||||
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
|
||||
if (!meta_class) {
|
||||
meta_class = std::make_shared<a8::reflect::Class>("MobaRoom", 7, 0);
|
||||
meta_class = std::make_shared<a8::reflect::Class>("MobaRoom", 8, 0);
|
||||
meta_class->SetSimpleField(0, "map_id", a8::reflect::ET_INT32, my_offsetof2(MobaRoom, map_id_));
|
||||
meta_class->SetSimpleField(1, "revive_time", a8::reflect::ET_INT32, my_offsetof2(MobaRoom, revive_time_));
|
||||
meta_class->SetSimpleField(2, "game_time", a8::reflect::ET_INT32, my_offsetof2(MobaRoom, game_time_));
|
||||
@ -123,6 +123,7 @@ namespace mtb
|
||||
meta_class->SetSimpleField(4, "tower_recover_hp_rate", a8::reflect::ET_FLOAT, my_offsetof2(MobaRoom, tower_recover_hp_rate_));
|
||||
meta_class->SetSimpleField(5, "towers", a8::reflect::ET_STRING, my_offsetof2(MobaRoom, towers_));
|
||||
meta_class->SetSimpleField(6, "monster_revive", a8::reflect::ET_STRING, my_offsetof2(MobaRoom, monster_revive_));
|
||||
meta_class->SetSimpleField(7, "batterys", a8::reflect::ET_STRING, my_offsetof2(MobaRoom, batterys_));
|
||||
}
|
||||
return meta_class;
|
||||
}
|
||||
|
@ -158,6 +158,17 @@ void Room::Init()
|
||||
}
|
||||
},
|
||||
&xtimer_attacher_);
|
||||
xtimer.SetIntervalWpEx
|
||||
(SERVER_FRAME_RATE * 3,
|
||||
[this] (int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
if (!IsGameOver() && !GetVictoryTeam()) {
|
||||
MobaBatterysUpdate();
|
||||
}
|
||||
}
|
||||
},
|
||||
&xtimer_attacher_);
|
||||
if (GetMapMeta()->GetMobaRoomMeta()->moba_towers.size() == 2) {
|
||||
xtimer.SetIntervalWpEx
|
||||
(SERVER_FRAME_RATE * GetMapMeta()->GetMobaRoomMeta()->tower_interval(),
|
||||
@ -3703,3 +3714,58 @@ bool Room::CanJoin(std::shared_ptr<CustomBattle> p)
|
||||
}
|
||||
return GetHumanNum() + p_team->GetMemberNum() <= GetRoomMaxPlayerNum();
|
||||
}
|
||||
|
||||
void Room::MobaBatterysUpdate()
|
||||
{
|
||||
for (int i = 0; i < GetMapMeta()->GetMobaRoomMeta()->moba_batterys.size(); ++i) {
|
||||
auto& tuple = GetMapMeta()->GetMobaRoomMeta()->moba_batterys.at(i);
|
||||
|
||||
int side = i + 1;
|
||||
glm::vec3 center = std::get<0>(tuple);
|
||||
CreatureWeakPtr target;
|
||||
float last_distance = 0;
|
||||
TraverseHumanList
|
||||
(
|
||||
[side, &target, ¢er, &tuple, &last_distance] (Human* hum) -> bool
|
||||
{
|
||||
if (hum->side != side) {
|
||||
float distance = hum->GetPos().Distance2D2(center);
|
||||
if (distance < std::get<1>(tuple)) {
|
||||
if (!target.Get() || distance < last_distance) {
|
||||
target = hum->GetWeakPtrRef();
|
||||
last_distance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (!target.Get()) {
|
||||
break;
|
||||
}
|
||||
|
||||
glm::vec3 bullet_dir = GlmHelper::UP;
|
||||
GlmHelper::RotateY(bullet_dir, glm::radians(1.0f + (float)(rand() % 360)));
|
||||
|
||||
const mt::Equip* weapon_meta = mt::Equip::GetById(std::get<2>(tuple));
|
||||
if (!weapon_meta) {
|
||||
return;
|
||||
}
|
||||
|
||||
glm::vec3 bullet_born_pos = std::get<0>(tuple);
|
||||
int bullet_uniid = AllocUniid();
|
||||
int shot_uniid = 0;
|
||||
frame_event.AddBullet
|
||||
(bullet_uniid,
|
||||
target,
|
||||
weapon_meta,
|
||||
1,
|
||||
bullet_born_pos,
|
||||
bullet_dir,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
shot_uniid,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +347,7 @@ private:
|
||||
void OnBattleStart();
|
||||
void ClearPostBattleAutoFreeList();
|
||||
void OnAddHuman(Human* hum);
|
||||
void MobaBatterysUpdate();
|
||||
|
||||
#ifdef MYDEBUG
|
||||
void InitDebugInfo();
|
||||
|
@ -55,6 +55,7 @@ message MobaRoom
|
||||
optional float tower_recover_hp_rate = 5;
|
||||
optional string towers = 6;
|
||||
optional string monster_revive = 7;
|
||||
optional string batterys = 8;
|
||||
}
|
||||
|
||||
message MapArea
|
||||
|
Loading…
x
Reference in New Issue
Block a user