This commit is contained in:
aozhiwei 2022-12-29 15:13:10 +08:00
parent e838f29fc0
commit 970a4de0d1
2 changed files with 70 additions and 65 deletions

View File

@ -19,7 +19,7 @@ void SprintBuff::Activate()
if (caster_.Get()->IsPlayer()) { if (caster_.Get()->IsPlayer()) {
SprintMove(); SprintMove();
CollisionCheck(); CoCollisionCheck();
} }
ProcSkill(); ProcSkill();
} }
@ -72,7 +72,7 @@ void SprintBuff::SprintMove()
#endif #endif
} }
void SprintBuff::CollisionCheck() void SprintBuff::CoCollisionCheck()
{ {
std::map<int, long long> hited_objects = std::map<int, long long>(); std::map<int, long long> hited_objects = std::map<int, long long>();
Position pre_pos; Position pre_pos;
@ -83,52 +83,59 @@ void SprintBuff::CollisionCheck()
[this, hited_objects, pre_pos] [this, hited_objects, pre_pos]
(int event, const a8::Args* args) mutable (int event, const a8::Args* args) mutable
{ {
Buff* buff = this; if (!meta->_param3_int_list.empty() || skill_meta) {
if (!buff->meta->_param3_int_list.empty() || buff->skill_meta) { Check(pre_pos, hited_objects);
std::set<Creature*> enemys; }
Position old_pos = buff->owner->GetPos(); },
&xtimer_attacher);
}
if (pre_pos.ManhattanDistance2D(buff->owner->GetPos()) > 2) { void SprintBuff::Check(Position& pre_pos, std::map<int, long long>& hited_objects)
a8::Vec2 dir = buff->owner->GetPos().CalcDir2D(pre_pos); {
std::set<Creature*> enemys;
Position old_pos = owner->GetPos();
if (pre_pos.ManhattanDistance2D(owner->GetPos()) > 2) {
a8::Vec2 dir = owner->GetPos().CalcDir2D(pre_pos);
dir.Normalize(); dir.Normalize();
float distance = buff->owner->GetPos().Distance2D2(pre_pos); float distance = owner->GetPos().Distance2D2(pre_pos);
for (int i = 0; i < (distance + 6); i += 5) { for (int i = 0; i < (distance + 6); i += 5) {
// 999 // 999
#if 1 #if 1
#else #else
buff->owner->MutablePos.FromVec2((pre_pos) + (dir * i)); owner->MutablePos.FromVec2((pre_pos) + (dir * i));
#endif #endif
buff->owner->GetHitEnemys(enemys, buff->meta->_param4); owner->GetHitEnemys(enemys, meta->_param4);
for (auto& enemy : enemys) { for (auto& enemy : enemys) {
if (enemy->IsEntityType(ET_Car)) { if (enemy->IsEntityType(ET_Car)) {
continue; continue;
} }
auto itr = hited_objects.find(enemy->GetUniId()); auto itr = hited_objects.find(enemy->GetUniId());
if (itr != hited_objects.end()) { if (itr != hited_objects.end()) {
if ((buff->owner->room->GetFrameNo() - itr->second) * FRAME_RATE_MS < if ((owner->room->GetFrameNo() - itr->second) * FRAME_RATE_MS <
buff->meta->_int_param5) { meta->_int_param5) {
continue; continue;
} }
} }
hited_objects[enemy->GetUniId()] = buff->owner->room->GetFrameNo(); hited_objects[enemy->GetUniId()] = owner->room->GetFrameNo();
for (int buff_id : buff->meta->_param3_int_list) { for (int buff_id : meta->_param3_int_list) {
enemy->TryAddBuff(buff->owner, buff_id); enemy->TryAddBuff(owner, buff_id);
} }
if (buff->skill_meta) { if (skill_meta) {
switch (buff->skill_meta->GetMagicId()) { switch (skill_meta->GetMagicId()) {
case MAGIC_YMCZ: case MAGIC_YMCZ:
{ {
float dmg = SkillHelper::GetYmczDmg(buff->owner, float dmg = SkillHelper::GetYmczDmg(owner,
enemy, enemy,
buff->skill_meta); skill_meta);
if (dmg > 0.0001f) { if (dmg > 0.0001f) {
enemy->DecHP( enemy->DecHP(
dmg, dmg,
buff->owner->GetUniId(), owner->GetUniId(),
buff->owner->GetName(), owner->GetName(),
0, 0,
buff->owner->GetUniId(), owner->GetUniId(),
buff->owner->GetName() owner->GetName()
); );
} }
} }
@ -143,11 +150,8 @@ void SprintBuff::CollisionCheck()
} }
} }
buff->owner->SetPos(old_pos); owner->SetPos(old_pos);
pre_pos = buff->owner->GetPos(); pre_pos = owner->GetPos();
}
},
&xtimer_attacher);
} }
void SprintBuff::ProcSkill() void SprintBuff::ProcSkill()

View File

@ -11,7 +11,8 @@ class SprintBuff : public Buff
private: private:
void SprintMove(); void SprintMove();
void CollisionCheck(); void CoCollisionCheck();
void Check(Position& pre_pos, std::map<int, long long>& hited_objects);
void ProcSkill(); void ProcSkill();
}; };