This commit is contained in:
aozhiwei 2024-01-17 14:23:05 +08:00
parent 261433b00d
commit 5a33ca8030
14 changed files with 0 additions and 759 deletions

View File

@ -66,7 +66,6 @@ class Trigger;
class DelayAddBuffHandle;
class Movement;
class Player;
class GunGrasp;
class Compose;
class Android;
class Creature : public MoveableEntity
@ -502,7 +501,6 @@ private:
std::map<int, long long> buff_interval_hash_;
std::array<Inventory, IS_END> inventory_ = {};
std::shared_ptr<GunGrasp> gun_grasp_;
std::shared_ptr<Compose> compose_;
std::map<int, a8::XTimerWp> ignore_target_hash_;
@ -528,5 +526,4 @@ private:
friend class Skill;
friend class Trigger;
friend class PBUtils;
friend class GunGrasp;
};

View File

@ -1,406 +0,0 @@
#include "precompile.h"
#include "guide.h"
#include "human.h"
#include "room.h"
#include "glmhelper.h"
#include "hero.h"
#include "trigger.h"
#include "skill.h"
#include "mt/GuideStep.h"
#include "mt/Hero.h"
#include "mt/Skill.h"
const static glm::vec3 HERO_DEFAULT_DIR = glm::vec3(0.181114614010,0.000000000000,-0.983461976051);
void Guide::Init(Human* owner)
{
owner_ = owner;
if (!owner_->room->IsNewBieRoom()) {
return;
}
if (mt::GuideStep::_steps.empty()) {
return;
}
curr_step_idx_ = 0;
UpdateStep();
owner_->room->xtimer.SetTimeoutEx
(
SERVER_FRAME_RATE * 60 * 10,
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
finished_ = true;
owner_->SendNewBieEnd();
}
},
&owner_->xtimer_attacher);
}
void Guide::UpdateStep()
{
curr_step_meta_ = mt::GuideStep::_steps.at(curr_step_idx_);
#ifdef MYDEBUG
a8::XPrintf("UpdateStep idx:%d id:%d target:%d\n",
{
curr_step_idx_,
curr_step_meta_->id(),
curr_step_meta_->target()
});
#endif
SyncStep();
switch (curr_step_meta_->target()) {
case mt::MOVE_TARGET_GUIDE_STEP:
{
ProcMoveTarget();
}
break;
case mt::PICKUP_GUIDE_STEP:
{
ProcPickup();
}
break;
case mt::KILL_ENEMY_GUIDE_STEP:
{
ProcKillEnemy();
}
break;
case mt::USE_SKILL_AND_KILL_ENEMY_GUIDE_STEP:
{
ProcUseSkillAndKillEnemy();
}
break;
case mt::USE_SKILL_GUIDE_STEP:
{
ProcUseSkill();
}
break;
default:
{
abort();
}
break;
}
}
void Guide::ProcMoveTarget()
{
owner_->room->xtimer.SetIntervalEx
(1,
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
if (!curr_step_meta_->_params.empty()) {
Position pos;
pos.FromGlmVec3(std::get<1>(curr_step_meta_->_params.at(0)));
if (owner_->GetPos().Distance2D2(pos) < 30) {
NextStep();
owner_->room->xtimer.DeleteCurrentTimer();
}
} else {
NextStep();
}
}
},
&owner_->xtimer_attacher);
}
void Guide::ProcPickup()
{
if (curr_step_meta_->_params.empty()) {
NextStep();
return;
}
auto context = A8_MAKE_ANON_STRUCT_SHARED
(
std::vector<int> loots;
);
{
int i = 0;
for (auto& tuple : curr_step_meta_->_params) {
int time = std::get<0>(tuple);
glm::vec3 pos = std::get<1>(tuple);
int equip_id = std::get<2>(tuple);
context->loots.push_back(-1);
owner_->room->xtimer.SetTimeoutEx
(
time / FRAME_RATE_MS,
[this, equip_id, pos, context, i ] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
context->loots[i] = owner_->room->CreateLoot
(
equip_id,
pos,
pos,
1,
1
);
if (context->loots[i] <= 0) {
abort();
}
}
},
&owner_->xtimer_attacher);
++i;
}
}
owner_->room->xtimer.SetIntervalEx
(1,
[this, context] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
bool done = true;
for (int loot_uniid : context->loots) {
if (loot_uniid == -1) {
done = false;
break;
}
if (owner_->room->GetEntityByUniId(loot_uniid)) {
done = false;
break;
}
}
if (done) {
NextStep();
owner_->room->xtimer.DeleteCurrentTimer();
}
}
},
&owner_->xtimer_attacher);
}
void Guide::ProcKillEnemy()
{
if (curr_step_meta_->_params.empty()) {
NextStep();
return;
}
auto context = A8_MAKE_ANON_STRUCT_SHARED
(
std::vector<int> heros;
);
{
int i = 0;
for (auto& tuple : curr_step_meta_->_params) {
int time = std::get<0>(tuple);
glm::vec3 pos = std::get<1>(tuple);
int hero_id = std::get<2>(tuple);
const mt::Hero* hero_meta = mt::Hero::GetById(hero_id);
if (!hero_meta){
continue;
}
context->heros.push_back(-1);
owner_->room->xtimer.SetTimeoutEx
(
time / FRAME_RATE_MS,
[this, hero_id, hero_meta, pos, context, i ] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
Hero* hero = owner_->room->CreateHero
(
nullptr,
hero_meta,
pos,
HERO_DEFAULT_DIR,
666
);
if (!hero) {
abort();
}
hero->SetHP(0.1f);
hero->SetMaxHP(0.1f);
context->heros[i] = hero->GetUniId();
}
},
&owner_->xtimer_attacher);
++i;
}
}
owner_->room->xtimer.SetIntervalEx
(1,
[this, context] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
bool done = true;
for (int hero_uniid : context->heros) {
if (hero_uniid <= 0) {
done = false;
break;
}
Entity* e = owner_->room->GetEntityByUniId(hero_uniid);
if (e && e->IsEntityType(ET_Hero)) {
Hero* hero = (Hero*)e;
if (!hero->dead) {
done = false;
break;
}
}
}
if (done) {
NextStep();
owner_->room->xtimer.DeleteCurrentTimer();
}
}
},
&owner_->xtimer_attacher);
}
void Guide::ProcUseSkillAndKillEnemy()
{
if (curr_step_meta_->_params.empty()) {
NextStep();
return;
}
auto context = A8_MAKE_ANON_STRUCT_SHARED
(
std::vector<int> heros;
std::vector<std::weak_ptr<EventHandler>> handlers;
);
{
int i = 0;
for (auto& tuple : curr_step_meta_->_params) {
int time = std::get<0>(tuple);
glm::vec3 pos = std::get<1>(tuple);
int hero_id = std::get<2>(tuple);
const mt::Hero* hero_meta = mt::Hero::GetById(hero_id);
if (!hero_meta){
continue;
}
context->heros.push_back(-1);
owner_->room->xtimer.SetTimeoutEx
(
time / FRAME_RATE_MS,
[this, hero_id, hero_meta, pos, context, i ] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
Hero* hero = owner_->room->CreateHero
(
nullptr,
hero_meta,
pos,
HERO_DEFAULT_DIR,
666
);
if (!hero) {
abort();
}
hero->SetHP(0.1f);
hero->SetMaxHP(0.1f);
context->heros[i] = hero->GetUniId();
}
},
&owner_->xtimer_attacher);
++i;
}
}
owner_->room->xtimer.SetIntervalEx
(1,
[this, context] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
bool done = true;
for (int hero_uniid : context->heros) {
if (hero_uniid <= 0) {
done = false;
break;
}
Entity* e = owner_->room->GetEntityByUniId(hero_uniid);
if (e && e->IsEntityType(ET_Hero)) {
Hero* hero = (Hero*)e;
if (!hero->dead) {
done = false;
break;
}
}
}
if (done) {
NextStep();
owner_->room->xtimer.DeleteCurrentTimer();
}
}
},
&owner_->xtimer_attacher);
context->handlers.push_back
(owner_->GetTrigger()->AddListener
(
kUseSkillEvent,
[this, context] (const a8::Args& args) mutable
{
Skill* skill = args.Get<Skill*>(0);
if (curr_step_meta_->_int_param1 == skill->GetBaseSkillMeta()->skill_id()) {
owner_->GetTrigger()->RemoveEventHandlers(context->handlers);
}
})
);
}
void Guide::ProcUseSkill()
{
auto context = A8_MAKE_ANON_STRUCT_SHARED
(
std::vector<std::weak_ptr<EventHandler>> handlers;
);
context->handlers.push_back
(owner_->GetTrigger()->AddListener
(
kUseSkillEvent,
[this, context] (const a8::Args& args) mutable
{
Skill* skill = args.Get<Skill*>(0);
if (curr_step_meta_->_int_param1 == skill->GetBaseSkillMeta()->skill_id()) {
NextStep();
owner_->GetTrigger()->RemoveEventHandlers(context->handlers);
}
})
);
}
void Guide::NextStep()
{
#ifdef MYDEBUG
a8::XPrintf("next step %d\n", {curr_step_idx_});
#endif
++curr_step_idx_;
if (curr_step_idx_ >= mt::GuideStep::_steps.size()) {
finished_ = true;
SyncStep();
owner_->SendNewBieEnd();
return;
}
UpdateStep();
}
void Guide::SyncStep()
{
if (IsFinished()) {
owner_->room->frame_event.AddPropChg
(
owner_->GetWeakPtrRef(),
kPropGuideStep,
-1,
0,
true);
} else {
owner_->room->frame_event.AddPropChg
(
owner_->GetWeakPtrRef(),
kPropGuideStep,
curr_step_meta_->id(),
0,
true);
}
}

View File

@ -1,34 +0,0 @@
#pragma once
namespace mt
{
class GuideStep;
}
class Human;
class Guide
{
public:
void Init(Human* owner);
void SyncStep();
bool IsFinished() { return finished_; };
private:
void UpdateStep();
void ProcMoveTarget();
void ProcPickup();
void ProcKillEnemy();
void ProcUseSkillAndKillEnemy();
void ProcUseSkill();
void NextStep();
private:
Human* owner_ = nullptr;
bool finished_ = false;
int curr_step_idx_ = 0;
const mt::GuideStep* curr_step_meta_ = nullptr;
};

View File

@ -42,7 +42,6 @@
#include "ability.h"
#include "stats.h"
#include "hero.h"
#include "guide.h"
#include "compose.h"
#include "bornpoint.h"
@ -95,7 +94,6 @@ Human::Human():Creature()
AddInventory(IS_ICE, FIGHTING_MODE_BULLET_NUM);
}
stats = std::make_shared<PlayerStats>();
guide_ = std::make_shared<Guide>();
}
Human::~Human()
@ -106,7 +104,6 @@ Human::~Human()
void Human::Initialize()
{
Creature::Initialize();
guide_->Init(this);
volume_ = meta->_volume;
observers_.insert(this);
SetCurrWeapon(&weapons[0]);

View File

@ -42,7 +42,6 @@ class Loot;
class Car;
class Buff;
class PlayerStats;
class Guide;
class MobaBattle;
struct BornPoint;
class Human : public Creature
@ -266,7 +265,6 @@ class Human : public Creature
void ProcThrowDmg(int throw_uniid);
void CalcStats();
void ShiledBreak();
std::shared_ptr<Guide> GetGuide() { return guide_; };
void SendNewBieEnd();
void LootInteraction(Loot* entity);
void ObstacleInteraction(Obstacle* entity);
@ -375,6 +373,5 @@ private:
float old_sync_speed = 0;
std::map<int, long long> attacker_hash_;
std::shared_ptr<Guide> guide_;
friend class PBUtils;
};

View File

@ -1,102 +0,0 @@
#include "precompile.h"
#include "mt/GuideStep.h"
IMPL_TABLE(mt::GuideStep)
std::vector<const mt::GuideStep*> mt::GuideStep::_steps;
namespace mt
{
void GuideStep::Init1()
{
_int_param1 = a8::XValue(param1());
std::vector<std::string> param_strs;
{
param_strs.push_back(param1());
param_strs.push_back(param2());
param_strs.push_back(param3());
param_strs.push_back(param4());
}
switch (target()) {
case MOVE_TARGET_GUIDE_STEP:
{
std::vector<std::string> strings;
a8::Split(param1(), strings, ':');
if (strings.size() != 3) {
abort();
}
_params.push_back(std::make_tuple
(
0,
glm::vec3(
(float)a8::XValue(strings[0]).GetDouble(),
(float)a8::XValue(strings[1]).GetDouble(),
(float)a8::XValue(strings[2]).GetDouble()
),
0));
}
break;
case PICKUP_GUIDE_STEP:
case KILL_ENEMY_GUIDE_STEP:
{
for (auto& str : param_strs) {
if (str.size() <= 0) {
break;
}
std::vector<std::string> strings;
a8::Split(str, strings, ':');
if (strings.size() != 5) {
abort();
}
_params.push_back(std::make_tuple
(
a8::XValue(strings[0]).GetInt(),
glm::vec3(
(float)a8::XValue(strings[1]).GetDouble(),
(float)a8::XValue(strings[2]).GetDouble(),
(float)a8::XValue(strings[3]).GetDouble()
),
a8::XValue(strings[4]).GetInt()));
}
}
break;
case USE_SKILL_AND_KILL_ENEMY_GUIDE_STEP:
{
for (size_t i = 1; i < param_strs.size(); ++i) {
std::string str = param_strs[i];
if (str.size() <= 0) {
break;
}
std::vector<std::string> strings;
a8::Split(str, strings, ':');
if (strings.size() != 5) {
abort();
}
_params.push_back(std::make_tuple
(
a8::XValue(strings[0]).GetInt(),
glm::vec3(
(float)a8::XValue(strings[1]).GetDouble(),
(float)a8::XValue(strings[2]).GetDouble(),
(float)a8::XValue(strings[3]).GetDouble()
),
a8::XValue(strings[4]).GetInt()));
}
}
break;
case USE_SKILL_GUIDE_STEP:
{
}
break;
default:
{
abort();
}
break;
}
_steps.push_back(this);
}
}

View File

@ -1,30 +0,0 @@
#pragma once
#include "mt/macro.h"
#include "mtb/GuideStep.h"
namespace mt
{
const int MOVE_TARGET_GUIDE_STEP = 1;
const int PICKUP_GUIDE_STEP = 2;
const int KILL_ENEMY_GUIDE_STEP = 3;
const int USE_SKILL_AND_KILL_ENEMY_GUIDE_STEP = 4;
const int USE_SKILL_GUIDE_STEP = 5;
DECLARE_ID_TABLE(GuideStep, mtb::GuideStep,
"guideStep@guideStep.json",
"id")
public:
void Init1();
int _int_param1 = 0;
std::vector<std::tuple<int, glm::vec3, int>> _params;
static std::vector<const mt::GuideStep*> _steps;
private:
};
}

View File

@ -35,7 +35,6 @@
#include "mt/SkillNumber.h"
#include "mt/MapArea.h"
#include "mt/MapCollider.h"
#include "mt/GuideStep.h"
#include "mt/MergeItem.h"
#include "mt/MapThingGroup.h"
#include "mt/SafeAreaSafePoint.h"
@ -109,7 +108,6 @@ namespace mt
RegMetaTable<Skill>(res_path_);
RegMetaTable<SkillNumber>(res_path_);
RegMetaTable<MapArea>(res_path_);
RegMetaTable<GuideStep>(res_path_);
RegMetaTable<MergeItem>(res_path_);
RegMetaTable<MapThingGroup>(res_path_);
RegMetaTable<SafeAreaSafePoint>(res_path_);

View File

@ -1,49 +0,0 @@
#pragma once
#include <bitset>
namespace mtb
{
class Grasp
{
public:
std::shared_ptr<a8::reflect::Class> GetClass() const;
int grasp_id() const { return grasp_id_; };
int hero_id() const { return hero_id_; };
int hero_lv() const { return hero_lv_; };
int graspbuff_id1() const { return graspbuff_id1_; };
int graspbuff_id1_floor2() const { return graspbuff_id1_floor2_; };
int graspbuff_id2() const { return graspbuff_id2_; };
int weapon_id() const { return weapon_id_; };
const std::string add_buff_list() const { return add_buff_list_; };
const std::string remove_buff_list() const { return remove_buff_list_; };
bool has_grasp_id() const { return __flags__.test(0);};
bool has_hero_id() const { return __flags__.test(1);};
bool has_hero_lv() const { return __flags__.test(2);};
bool has_graspbuff_id1() const { return __flags__.test(3);};
bool has_graspbuff_id1_floor2() const { return __flags__.test(4);};
bool has_graspbuff_id2() const { return __flags__.test(5);};
bool has_weapon_id() const { return __flags__.test(6);};
bool has_add_buff_list() const { return __flags__.test(7);};
bool has_remove_buff_list() const { return __flags__.test(8);};
protected:
int grasp_id_ = 0;
int hero_id_ = 0;
int hero_lv_ = 0;
int graspbuff_id1_ = 0;
int graspbuff_id1_floor2_ = 0;
int graspbuff_id2_ = 0;
int weapon_id_ = 0;
std::string add_buff_list_;
std::string remove_buff_list_;
public:
std::bitset<9> __flags__;
};
};

View File

@ -1,52 +0,0 @@
#pragma once
#include <bitset>
namespace mtb
{
class GraspBuff
{
public:
std::shared_ptr<a8::reflect::Class> GetClass() const;
int graspbuff_id() const { return graspbuff_id_; };
int graspbuff_floor() const { return graspbuff_floor_; };
const std::string graspbuff_trigger() const { return graspbuff_trigger_; };
int graspbuff_target() const { return graspbuff_target_; };
const std::string graspbuff_time() const { return graspbuff_time_; };
int attr_id() const { return attr_id_; };
int attr_add_pattern() const { return attr_add_pattern_; };
int attr_add_pattern2() const { return attr_add_pattern2_; };
const std::string attr_num() const { return attr_num_; };
const std::string effect_list() const { return effect_list_; };
bool has_graspbuff_id() const { return __flags__.test(0);};
bool has_graspbuff_floor() const { return __flags__.test(1);};
bool has_graspbuff_trigger() const { return __flags__.test(2);};
bool has_graspbuff_target() const { return __flags__.test(3);};
bool has_graspbuff_time() const { return __flags__.test(4);};
bool has_attr_id() const { return __flags__.test(5);};
bool has_attr_add_pattern() const { return __flags__.test(6);};
bool has_attr_add_pattern2() const { return __flags__.test(7);};
bool has_attr_num() const { return __flags__.test(8);};
bool has_effect_list() const { return __flags__.test(9);};
protected:
int graspbuff_id_ = 0;
int graspbuff_floor_ = 0;
std::string graspbuff_trigger_;
int graspbuff_target_ = 0;
std::string graspbuff_time_;
int attr_id_ = 0;
int attr_add_pattern_ = 0;
int attr_add_pattern2_ = 0;
std::string attr_num_;
std::string effect_list_;
public:
std::bitset<10> __flags__;
};
};

View File

@ -1,40 +0,0 @@
#pragma once
#include <bitset>
namespace mtb
{
class GuideStep
{
public:
std::shared_ptr<a8::reflect::Class> GetClass() const;
int id() const { return id_; };
int target() const { return target_; };
const std::string param1() const { return param1_; };
const std::string param2() const { return param2_; };
const std::string param3() const { return param3_; };
const std::string param4() const { return param4_; };
bool has_id() const { return __flags__.test(0);};
bool has_target() const { return __flags__.test(1);};
bool has_param1() const { return __flags__.test(2);};
bool has_param2() const { return __flags__.test(3);};
bool has_param3() const { return __flags__.test(4);};
bool has_param4() const { return __flags__.test(5);};
protected:
int id_ = 0;
int target_ = 0;
std::string param1_;
std::string param2_;
std::string param3_;
std::string param4_;
public:
std::bitset<6> __flags__;
};
};

View File

@ -35,7 +35,6 @@
#include "mtb/PveGeminiContent.h"
#include "mtb/PveGeminiMode.h"
#include "mtb/RankRoom.h"
#include "mtb/GuideStep.h"
#include "mtb/WorldObject.h"
#include "mtb/MergeItem.h"
#include "mtb/MapThingGroup.h"
@ -803,21 +802,6 @@ namespace mtb
return meta_class;
}
std::shared_ptr<a8::reflect::Class> GuideStep::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
if (!meta_class) {
meta_class = std::make_shared<a8::reflect::Class>("GuideStep", 6, 0);
meta_class->SetSimpleField(0, "id", a8::reflect::ET_INT32, my_offsetof2(GuideStep, id_));
meta_class->SetSimpleField(1, "target", a8::reflect::ET_INT32, my_offsetof2(GuideStep, target_));
meta_class->SetSimpleField(2, "param1", a8::reflect::ET_STRING, my_offsetof2(GuideStep, param1_));
meta_class->SetSimpleField(3, "param2", a8::reflect::ET_STRING, my_offsetof2(GuideStep, param2_));
meta_class->SetSimpleField(4, "param3", a8::reflect::ET_STRING, my_offsetof2(GuideStep, param3_));
meta_class->SetSimpleField(5, "param4", a8::reflect::ET_STRING, my_offsetof2(GuideStep, param4_));
}
return meta_class;
}
std::shared_ptr<a8::reflect::Class> WorldObject::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;

View File

@ -32,7 +32,6 @@
#include "ability.h"
#include "buff.h"
#include "stats.h"
#include "guide.h"
#include "mapinstance.h"
#include "compose.h"
#include "debugcmd.h"
@ -916,14 +915,6 @@ void Player::_CMReconnect(f8::MsgHdr* hdr, const cs::CMReconnect& msg)
},
&xtimer_attacher);
}
{
if (room->IsNewBieRoom()) {
GetGuide()->SyncStep();
if (GetGuide()->IsFinished()) {
SendNewBieEnd();
}
}
}
if (!room->game_over_timer.expired()) {
room->xtimer.Delete(room->game_over_timer);
}

View File

@ -602,16 +602,6 @@ message RankRoom
optional int32 final_player_num = 10;
}
message GuideStep
{
optional int32 id = 1;
optional int32 target = 2;
optional string param1 = 3;
optional string param2 = 4;
optional string param3 = 5;
optional string param4 = 6;
}
message WorldObject
{
optional int32 object_id= 1;