1
This commit is contained in:
parent
e838f29fc0
commit
970a4de0d1
@ -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,73 +83,77 @@ 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();
|
|
||||||
|
|
||||||
if (pre_pos.ManhattanDistance2D(buff->owner->GetPos()) > 2) {
|
|
||||||
a8::Vec2 dir = buff->owner->GetPos().CalcDir2D(pre_pos);
|
|
||||||
dir.Normalize();
|
|
||||||
float distance = buff->owner->GetPos().Distance2D2(pre_pos);
|
|
||||||
for (int i = 0; i < (distance + 6); i += 5) {
|
|
||||||
// 999
|
|
||||||
#if 1
|
|
||||||
#else
|
|
||||||
buff->owner->MutablePos.FromVec2((pre_pos) + (dir * i));
|
|
||||||
#endif
|
|
||||||
buff->owner->GetHitEnemys(enemys, buff->meta->_param4);
|
|
||||||
for (auto& enemy : enemys) {
|
|
||||||
if (enemy->IsEntityType(ET_Car)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto itr = hited_objects.find(enemy->GetUniId());
|
|
||||||
if (itr != hited_objects.end()) {
|
|
||||||
if ((buff->owner->room->GetFrameNo() - itr->second) * FRAME_RATE_MS <
|
|
||||||
buff->meta->_int_param5) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hited_objects[enemy->GetUniId()] = buff->owner->room->GetFrameNo();
|
|
||||||
for (int buff_id : buff->meta->_param3_int_list) {
|
|
||||||
enemy->TryAddBuff(buff->owner, buff_id);
|
|
||||||
}
|
|
||||||
if (buff->skill_meta) {
|
|
||||||
switch (buff->skill_meta->GetMagicId()) {
|
|
||||||
case MAGIC_YMCZ:
|
|
||||||
{
|
|
||||||
float dmg = SkillHelper::GetYmczDmg(buff->owner,
|
|
||||||
enemy,
|
|
||||||
buff->skill_meta);
|
|
||||||
if (dmg > 0.0001f) {
|
|
||||||
enemy->DecHP(
|
|
||||||
dmg,
|
|
||||||
buff->owner->GetUniId(),
|
|
||||||
buff->owner->GetName(),
|
|
||||||
0,
|
|
||||||
buff->owner->GetUniId(),
|
|
||||||
buff->owner->GetName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buff->owner->SetPos(old_pos);
|
|
||||||
pre_pos = buff->owner->GetPos();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
&xtimer_attacher);
|
&xtimer_attacher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SprintBuff::Check(Position& pre_pos, std::map<int, long long>& hited_objects)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
float distance = owner->GetPos().Distance2D2(pre_pos);
|
||||||
|
for (int i = 0; i < (distance + 6); i += 5) {
|
||||||
|
// 999
|
||||||
|
#if 1
|
||||||
|
#else
|
||||||
|
owner->MutablePos.FromVec2((pre_pos) + (dir * i));
|
||||||
|
#endif
|
||||||
|
owner->GetHitEnemys(enemys, meta->_param4);
|
||||||
|
for (auto& enemy : enemys) {
|
||||||
|
if (enemy->IsEntityType(ET_Car)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto itr = hited_objects.find(enemy->GetUniId());
|
||||||
|
if (itr != hited_objects.end()) {
|
||||||
|
if ((owner->room->GetFrameNo() - itr->second) * FRAME_RATE_MS <
|
||||||
|
meta->_int_param5) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hited_objects[enemy->GetUniId()] = owner->room->GetFrameNo();
|
||||||
|
for (int buff_id : meta->_param3_int_list) {
|
||||||
|
enemy->TryAddBuff(owner, buff_id);
|
||||||
|
}
|
||||||
|
if (skill_meta) {
|
||||||
|
switch (skill_meta->GetMagicId()) {
|
||||||
|
case MAGIC_YMCZ:
|
||||||
|
{
|
||||||
|
float dmg = SkillHelper::GetYmczDmg(owner,
|
||||||
|
enemy,
|
||||||
|
skill_meta);
|
||||||
|
if (dmg > 0.0001f) {
|
||||||
|
enemy->DecHP(
|
||||||
|
dmg,
|
||||||
|
owner->GetUniId(),
|
||||||
|
owner->GetName(),
|
||||||
|
0,
|
||||||
|
owner->GetUniId(),
|
||||||
|
owner->GetName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
owner->SetPos(old_pos);
|
||||||
|
pre_pos = owner->GetPos();
|
||||||
|
}
|
||||||
|
|
||||||
void SprintBuff::ProcSkill()
|
void SprintBuff::ProcSkill()
|
||||||
{
|
{
|
||||||
if (skill_meta) {
|
if (skill_meta) {
|
||||||
|
@ -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();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user