This commit is contained in:
aozhiwei 2023-04-07 18:19:04 +08:00
parent de3518736d
commit 876fb6e6fa
5 changed files with 45 additions and 2 deletions

View File

@ -17,6 +17,21 @@ namespace mt
if (_skin_id.size() != 3) { if (_skin_id.size() != 3) {
A8_ABORT(); A8_ABORT();
} }
{
std::vector<std::string> strings;
a8::Split(bullet_offset(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
if (strings2.size() != 2) {
abort();
}
float angle = a8::XValue(strings2[0]).GetDouble();
int rnd = a8::XValue(strings2[1]).GetInt();
_bullet_offset_rand_space += rnd;
_bullet_offset.push_back(std::make_tuple(angle, _bullet_offset_rand_space));
}
}
} }
const mt::Robot* Robot::RandRobot(std::set<int>& refreshed_robot_set) const mt::Robot* Robot::RandRobot(std::set<int>& refreshed_robot_set)
@ -34,4 +49,17 @@ namespace mt
} }
} }
float Robot::RandBulletAngleOfsset() const
{
if (_bullet_offset_rand_space > 0) {
int rnd = rand() % _bullet_offset_rand_space;
for (auto& tuple : _bullet_offset) {
if (rnd < std::get<1>(tuple)) {
return std::get<0>(tuple);
}
}
}
return 0.0f;
}
} }

View File

@ -15,6 +15,11 @@ namespace mt
static const mt::Robot* RandRobot(std::set<int>& refreshed_robot_set); static const mt::Robot* RandRobot(std::set<int>& refreshed_robot_set);
std::vector<int> _skin_id; std::vector<int> _skin_id;
float RandBulletAngleOfsset() const;
private:
int _bullet_offset_rand_space = 0;
std::vector<std::tuple<float, int>> _bullet_offset;
}; };
} }

View File

@ -17,6 +17,8 @@ namespace mtb
int weapon_id() const { return weapon_id_; }; int weapon_id() const { return weapon_id_; };
int weapon_lv() const { return weapon_lv_; }; int weapon_lv() const { return weapon_lv_; };
int sex() const { return sex_; }; int sex() const { return sex_; };
float dmg_ratio() const { return dmg_ratio_; };
const std::string bullet_offset() const { return bullet_offset_; };
bool has_id() const { return __flags__.test(0);}; bool has_id() const { return __flags__.test(0);};
bool has_name() const { return __flags__.test(1);}; bool has_name() const { return __flags__.test(1);};
@ -25,6 +27,8 @@ namespace mtb
bool has_weapon_id() const { return __flags__.test(4);}; bool has_weapon_id() const { return __flags__.test(4);};
bool has_weapon_lv() const { return __flags__.test(5);}; bool has_weapon_lv() const { return __flags__.test(5);};
bool has_sex() const { return __flags__.test(6);}; bool has_sex() const { return __flags__.test(6);};
bool has_dmg_ratio() const { return __flags__.test(7);};
bool has_bullet_offset() const { return __flags__.test(8);};
protected: protected:
@ -35,9 +39,11 @@ namespace mtb
int weapon_id_ = 0; int weapon_id_ = 0;
int weapon_lv_ = 0; int weapon_lv_ = 0;
int sex_ = 0; int sex_ = 0;
float dmg_ratio_ = 0.0f;
std::string bullet_offset_;
public: public:
std::bitset<7> __flags__; std::bitset<9> __flags__;
}; };
}; };

View File

@ -348,7 +348,7 @@ namespace mtb
{ {
a8::reflect::Class* meta_class = nullptr; a8::reflect::Class* meta_class = nullptr;
if (!meta_class) { if (!meta_class) {
meta_class = new a8::reflect::Class("Robot", 7, 0); meta_class = new a8::reflect::Class("Robot", 9, 0);
meta_class->SetSimpleField(0, "id", a8::reflect::ET_INT32, my_offsetof2(Robot, id_)); meta_class->SetSimpleField(0, "id", a8::reflect::ET_INT32, my_offsetof2(Robot, id_));
meta_class->SetSimpleField(1, "name", a8::reflect::ET_STRING, my_offsetof2(Robot, name_)); meta_class->SetSimpleField(1, "name", a8::reflect::ET_STRING, my_offsetof2(Robot, name_));
meta_class->SetSimpleField(2, "hero_id", a8::reflect::ET_INT32, my_offsetof2(Robot, hero_id_)); meta_class->SetSimpleField(2, "hero_id", a8::reflect::ET_INT32, my_offsetof2(Robot, hero_id_));
@ -356,6 +356,8 @@ namespace mtb
meta_class->SetSimpleField(4, "weapon_id", a8::reflect::ET_INT32, my_offsetof2(Robot, weapon_id_)); meta_class->SetSimpleField(4, "weapon_id", a8::reflect::ET_INT32, my_offsetof2(Robot, weapon_id_));
meta_class->SetSimpleField(5, "weapon_lv", a8::reflect::ET_INT32, my_offsetof2(Robot, weapon_lv_)); meta_class->SetSimpleField(5, "weapon_lv", a8::reflect::ET_INT32, my_offsetof2(Robot, weapon_lv_));
meta_class->SetSimpleField(6, "sex", a8::reflect::ET_INT32, my_offsetof2(Robot, sex_)); meta_class->SetSimpleField(6, "sex", a8::reflect::ET_INT32, my_offsetof2(Robot, sex_));
meta_class->SetSimpleField(7, "dmg_ratio", a8::reflect::ET_FLOAT, my_offsetof2(Robot, dmg_ratio_));
meta_class->SetSimpleField(8, "bullet_offset", a8::reflect::ET_STRING, my_offsetof2(Robot, bullet_offset_));
} }
return meta_class; return meta_class;
} }

View File

@ -276,6 +276,8 @@ message Robot
optional int32 weapon_lv = 5; optional int32 weapon_lv = 5;
optional int32 sex = 8; optional int32 sex = 8;
optional float dmg_ratio = 20;
optional string bullet_offset = 21;
} }
message Skill message Skill