This commit is contained in:
aozhiwei 2023-06-15 11:35:31 +08:00
commit 3ca27125f5
7 changed files with 105 additions and 17 deletions

View File

@ -2366,7 +2366,19 @@ void Creature::UpdateMove()
} }
} }
room->grid_service->MoveCreature(this); room->grid_service->MoveCreature(this);
if (room->IsPveRoom() && IsEntityType(ET_Hero) && IsNearGas()) { if (a8::HasBitFlag(status, CS_CrazeMode) && IsNearGas(100)) {
GetMutablePos() = old_pos;
GetMovement()->ClearPath();
glm::vec2 dir2 = room->GetGasData().pos_new - room->GetGasData().pos_old;
glm::vec3 dir = glm::vec3(dir2.x, 0.0f, dir2.y);
if (std::abs(dir.x) > FLT_EPSILON ||
std::abs(dir.y) > FLT_EPSILON ||
std::abs(dir.z) > FLT_EPSILON
) {
GlmHelper::Normalize(dir);
SetMoveDir(dir);
}
} else if (room->IsPveRoom() && IsEntityType(ET_Hero) && IsNearGas(20)) {
GetMutablePos() = old_pos; GetMutablePos() = old_pos;
GetMovement()->ClearPath(); GetMovement()->ClearPath();
glm::vec3 dir = GetPos().ToGlmVec3() - old_pos.ToGlmVec3(); glm::vec3 dir = GetPos().ToGlmVec3() - old_pos.ToGlmVec3();
@ -2377,7 +2389,7 @@ void Creature::UpdateMove()
GlmHelper::Normalize(dir); GlmHelper::Normalize(dir);
SetMoveDir(dir); SetMoveDir(dir);
} }
} else if (room->IsNewBieRoom() && IsNearGas()) { } else if (room->IsNewBieRoom() && IsNearGas(20)) {
GetMutablePos() = old_pos; GetMutablePos() = old_pos;
GetMovement()->ClearPath(); GetMovement()->ClearPath();
} }
@ -2979,12 +2991,12 @@ void Creature::NetInitOk()
{ {
} }
bool Creature::IsNearGas() bool Creature::IsNearGas(float distance)
{ {
Position p; Position p;
p.FromGlmVec3(glm::vec3(room->GetGasData().pos_new.x, 0, room->GetGasData().pos_new.y)); p.FromGlmVec3(glm::vec3(room->GetGasData().pos_new.x, 0, room->GetGasData().pos_new.y));
float distance = GetPos().Distance2D2(p); float gas_distance = GetPos().Distance2D2(p);
return distance + GetRadius() * 2 + 20 > room->GetGasData().rad_new; return gas_distance + GetRadius() * 2 + distance > room->GetGasData().rad_new;
} }
float Creature::GetSpeed() float Creature::GetSpeed()

View File

@ -16,6 +16,8 @@ enum CreatureStatus
CS_PreDieSuspended, CS_PreDieSuspended,
CS_DeadNoDrop, CS_DeadNoDrop,
CS_Reviving, CS_Reviving,
CS_CrazeMode,
CS_DisableAttackAndroid,
CS_End CS_End
}; };
@ -122,6 +124,8 @@ class Creature : public MoveableEntity
bool shot_start = false; bool shot_start = false;
bool shot_hold = false; bool shot_hold = false;
a8::XTimerWp craze_mode_timer;
Creature(); Creature();
virtual ~Creature() override; virtual ~Creature() override;
virtual void Initialize() override; virtual void Initialize() override;
@ -351,7 +355,7 @@ class Creature : public MoveableEntity
void ShortFindPath(); void ShortFindPath();
float GetSkillRaycastDistance(); float GetSkillRaycastDistance();
virtual void NetInitOk(); virtual void NetInitOk();
bool IsNearGas(); bool IsNearGas(float distance);
std::shared_ptr<std::set<int>> CalcReporterList(bool is_trace_bullet, std::shared_ptr<std::set<int>> CalcReporterList(bool is_trace_bullet,
const mt::Equip* weapon_meta, const mt::Equip* weapon_meta,
const mt::Equip* bullet_meta); const mt::Equip* bullet_meta);

View File

@ -17,6 +17,7 @@
#include "mt/PveGeminiMode.h" #include "mt/PveGeminiMode.h"
#include "mt/PveGeminiContent.h" #include "mt/PveGeminiContent.h"
#include "mt/Text.h" #include "mt/Text.h"
#include "mt/SafeArea.h"
void Incubator::Init() void Incubator::Init()
{ {
@ -151,6 +152,9 @@ void Incubator::AllocAndroid(Human* target, int num, std::vector<Human*>* androi
room->BroadcastDebugMsg(a8::Format("投放机器人 分配失败 %d", {hold_humans_.size()})); room->BroadcastDebugMsg(a8::Format("投放机器人 分配失败 %d", {hold_humans_.size()}));
} }
#endif #endif
if (hold_humans_.size() <= 6 && room->GetGasData().new_area_meta->GetSmallRingCount() < 3) {
ShowHand();
}
} }
void Incubator::RecycleAndroid(Human* hum) void Incubator::RecycleAndroid(Human* hum)
@ -244,7 +248,7 @@ void Incubator::AutoAllocAndroid()
killer->GetCurrWeapon()->weapon_id, killer->GetCurrWeapon()->weapon_id,
killer->GetUniId(), killer->GetUniId(),
killer->name); killer->name);
} else if (room->GetGasData().gas_count > 1) { } else if (room->GetGasData().gas_count > 2) {
hum->BeKill(VP_Gas, hum->BeKill(VP_Gas,
TEXT("battle_server_killer_gas", "毒圈"), TEXT("battle_server_killer_gas", "毒圈"),
VW_Gas, VW_Gas,
@ -471,3 +475,35 @@ void Incubator::NextWave()
#endif #endif
} }
} }
void Incubator::ShowHand()
{
#ifdef DEBUG
a8::XPrintf("ShowHand\n", {});
#endif
for (auto& hum : hold_humans_) {
glm::vec3 point = glm::vec3(room->GetGasData().new_area_meta->GetLastArea()->x1(),
6.0f,
room->GetGasData().new_area_meta->GetLastArea()->y1());
Global::Instance()->verify_set_pos = 1;
hum->GetMutablePos().FromGlmVec3(point);
Global::Instance()->verify_set_pos = 0;
a8::SetBitFlag(hum->status, CS_CrazeMode);
a8::SetBitFlag(hum->status, CS_DisableAttackAndroid);
room->xtimer.SetTimeoutEx
(
SERVER_FRAME_RATE * 20,
[hum] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
a8::UnSetBitFlag(hum->status, CS_DisableAttackAndroid);
}
},
&hum->xtimer_attacher);
room->EnableHuman(hum);
hum->MustBeAddBuff(hum, kTraceBuffId);
}
hold_humans_.clear();
}

View File

@ -24,6 +24,7 @@ private:
void AutoAllocAndroid(); void AutoAllocAndroid();
void OnEnterNewWave(int wave); void OnEnterNewWave(int wave);
void SpawnWaveMon(int wave); void SpawnWaveMon(int wave);
void ShowHand();
private: private:
int wait_alloc_time_ = 0; int wait_alloc_time_ = 0;

View File

@ -4,15 +4,26 @@
IMPL_TABLE(mt::SafeArea) IMPL_TABLE(mt::SafeArea)
std::map<int, const mt::SafeArea*> mt::SafeArea::type_hash_; std::map<int, std::vector<mt::SafeArea*>> mt::SafeArea::type_hash_;
namespace mt namespace mt
{ {
void SafeArea::Init1() void SafeArea::Init1()
{ {
if (!GetByType(type())) { {
type_hash_[type()] = this; auto itr = type_hash_.find(type());
if (itr == type_hash_.end()) {
type_hash_[type()] = std::vector<mt::SafeArea*>({this});
} else {
if (itr->second.empty()) {
abort();
}
if (itr->second.at(itr->second.size() - 1)->id() + 1 != id()) {
abort();
}
itr->second.push_back(this);
}
} }
if (!boss().empty()) { if (!boss().empty()) {
std::vector<std::string> strings; std::vector<std::string> strings;
@ -32,10 +43,25 @@ namespace mt
} }
} }
void SafeArea::StaticPostInit()
{
for (auto& pair : type_hash_) {
if (pair.second.size() < 1) {
abort();
}
int ring_count = pair.second.size() - 1;
auto last_area = pair.second.at(pair.second.size() - 1);
for (auto& meta : pair.second) {
meta->small_ring_count_ = ring_count--;
meta->last_area_ = last_area;
}
}
}
const SafeArea* SafeArea::GetByType(int type) const SafeArea* SafeArea::GetByType(int type)
{ {
auto itr = type_hash_.find(type); auto itr = type_hash_.find(type);
return itr != type_hash_.end() ? itr->second : nullptr; return itr != type_hash_.end() ? itr->second.at(0) : nullptr;
} }
} }

View File

@ -12,13 +12,18 @@ namespace mt
public: public:
void Init1(); void Init1();
static void StaticPostInit();
std::shared_ptr<std::tuple<glm::vec3, float, int>> GetBoss() const { return _boss; } std::shared_ptr<std::tuple<glm::vec3, float, int>> GetBoss() const { return _boss; }
int GetSmallRingCount() const { return small_ring_count_; }
const mt::SafeArea* GetLastArea() const { return last_area_; }
static const SafeArea* GetByType(int type); static const SafeArea* GetByType(int type);
private: private:
static std::map<int, const SafeArea*> type_hash_; static std::map<int, std::vector<mt::SafeArea*>> type_hash_;
int small_ring_count_ = 0;
const mt::SafeArea* last_area_ = nullptr;
std::shared_ptr<std::tuple<glm::vec3, float, int>> _boss; std::shared_ptr<std::tuple<glm::vec3, float, int>> _boss;
}; };

View File

@ -455,11 +455,15 @@ Human* Room::FindEnemy(Human* hum, float range)
if (!hum->dead && if (!hum->dead &&
!a8::HasBitFlag(hum->status, CS_Disable) && !a8::HasBitFlag(hum->status, CS_Disable) &&
hum->team_id != myself->team_id) { hum->team_id != myself->team_id) {
float distance = hum->GetPos().Distance2D2(myself->GetPos()); if (a8::HasBitFlag(hum->status, CS_DisableAttackAndroid) &&
if (distance <= range) { target->IsAndroid()) {
if (distance < last_distance) { } else {
target = hum; float distance = hum->GetPos().Distance2D2(myself->GetPos());
last_distance = distance; if (distance <= range) {
if (distance < last_distance) {
target = hum;
last_distance = distance;
}
} }
} }
} }