修复冲撞问题

This commit is contained in:
aozhiwei 2019-07-24 18:01:59 +08:00
parent bb2bb7244e
commit 1d10c6d3e5
4 changed files with 26 additions and 2 deletions

View File

@ -1615,7 +1615,7 @@ void Human::_UpdateAssaultMove()
std::set<Entity*> target_list;
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < hum->GetRadius()) {
if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < phase->param3.GetDouble()) {
if (!hum->HasBuffEffect(kBET_Invincible)) {
float power = phase->param1.GetDouble() + ability.atk;
float def = hum->ability.def;
@ -1623,11 +1623,25 @@ void Human::_UpdateAssaultMove()
hum->DecHP(finally_dmg, entity_uniid, name, 0);
target_list.insert(hum);
}
a8::Vec2 push_dir = skill_dir;
a8::Vec2 push_dir = hum->pos - skill_target_pos;
if (std::abs(push_dir.x) > FLT_EPSILON ||
std::abs(push_dir.y) > FLT_EPSILON) {
push_dir.Normalize();
skill_dir.Normalize();
a8::Vec2 old_push_dir = push_dir;
push_dir.x = old_push_dir.y;
push_dir.y = old_push_dir.x;
if (skill_dir.CalcAngle(push_dir) < 0.001f) {
push_dir = skill_dir;
}
hum->PushHuman(push_dir, phase->param2.GetDouble());
} else {
push_dir = skill_dir;
if (std::abs(push_dir.x) > FLT_EPSILON ||
std::abs(push_dir.y) > FLT_EPSILON) {
push_dir.Normalize();
hum->PushHuman(push_dir, phase->param2.GetDouble());
}
}
}
}

View File

@ -339,9 +339,14 @@ namespace MetaData
auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_param2", {idx}));
phase.param2_str = reflection->GetString(*(metatable::Skill*)i, field_desc);
}
{
auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_param3", {idx}));
phase.param3_str = reflection->GetString(*(metatable::Skill*)i, field_desc);
}
if (phase.func_id != kSkill_FuncNone) {
phase.param1 = a8::XValue(phase.param1_str);
phase.param2 = a8::XValue(phase.param2_str);
phase.param3 = a8::XValue(phase.param3_str);
phases.push_back(phase);
}
}

View File

@ -151,9 +151,11 @@ namespace MetaData
SkillFunc_e func_id = kSkill_FuncNone;
a8::XValue param1;
a8::XValue param2;
a8::XValue param3;
std::string param1_str;
std::string param2_str;
std::string param3_str;
};
struct Skill

View File

@ -125,16 +125,19 @@ message Skill
optional int32 phase1_func = 21;
optional string phase1_param1 = 22;
optional string phase1_param2 = 23;
optional string phase1_param3 = 24;
optional int32 phase2_time_offset = 30;
optional int32 phase2_func = 31;
optional string phase2_param1 = 32;
optional string phase2_param2 = 33;
optional string phase2_param3 = 34;
optional int32 phase3_time_offset = 40;
optional int32 phase3_func = 41;
optional string phase3_param1 = 42;
optional string phase3_param2 = 43;
optional string phase3_param3 = 44;
}