1
This commit is contained in:
parent
2433141484
commit
9eaf1c84b0
@ -28,11 +28,11 @@ void SprintBuff::Activate()
|
||||
{
|
||||
owner->SendDebugMsg(a8::Format("xxxxxxxx move_dir:%d,%d attack_dir:%d,%d speed:%d",
|
||||
{
|
||||
owner->GetMoveDir().x,
|
||||
owner->GetMoveDir().y,
|
||||
owner->GetAttackDir().x,
|
||||
owner->GetAttackDir().y,
|
||||
owner->GetSpeed()
|
||||
owner->GetMoveDir().x,
|
||||
owner->GetMoveDir().y,
|
||||
owner->GetAttackDir().x,
|
||||
owner->GetAttackDir().y,
|
||||
owner->GetSpeed()
|
||||
}));
|
||||
owner->room->xtimer.SetIntervalEx
|
||||
(
|
||||
@ -43,12 +43,12 @@ void SprintBuff::Activate()
|
||||
Human* hum = owner->AsHuman();
|
||||
hum->SendDebugMsg(a8::Format("xxxxxxxx move_dir:%d,%d attack_dir:%d,%d speed:%d",
|
||||
{
|
||||
hum->GetMoveDir().x,
|
||||
hum->GetMoveDir().y,
|
||||
hum->GetAttackDir().x,
|
||||
hum->GetAttackDir().y,
|
||||
hum->GetSpeed()
|
||||
}));
|
||||
hum->GetMoveDir().x,
|
||||
hum->GetMoveDir().y,
|
||||
hum->GetAttackDir().x,
|
||||
hum->GetAttackDir().y,
|
||||
hum->GetSpeed()
|
||||
}));
|
||||
}
|
||||
},
|
||||
&xtimer_attacher
|
||||
@ -56,81 +56,7 @@ void SprintBuff::Activate()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Player* hum = (Player*)caster_.Get();
|
||||
std::map<int, long long> hited_objects = std::map<int, long long>();
|
||||
Position pre_pos;
|
||||
pre_pos = owner->GetPos();
|
||||
owner->room->xtimer.SetIntervalEx
|
||||
(
|
||||
1,
|
||||
[this, hited_objects, pre_pos]
|
||||
(int event, const a8::Args* args) mutable
|
||||
{
|
||||
Buff* buff = this;
|
||||
if (!buff->meta->_param3_int_list.empty() || buff->skill_meta) {
|
||||
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);
|
||||
CollisionCheck();
|
||||
}
|
||||
ProcSkill();
|
||||
}
|
||||
@ -145,6 +71,84 @@ void SprintBuff::Deactivate()
|
||||
}
|
||||
}
|
||||
|
||||
void SprintBuff::CollisionCheck()
|
||||
{
|
||||
std::map<int, long long> hited_objects = std::map<int, long long>();
|
||||
Position pre_pos;
|
||||
pre_pos = owner->GetPos();
|
||||
owner->room->xtimer.SetIntervalEx
|
||||
(
|
||||
1,
|
||||
[this, hited_objects, pre_pos]
|
||||
(int event, const a8::Args* args) mutable
|
||||
{
|
||||
Buff* buff = this;
|
||||
if (!buff->meta->_param3_int_list.empty() || buff->skill_meta) {
|
||||
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);
|
||||
}
|
||||
|
||||
void SprintBuff::ProcSkill()
|
||||
{
|
||||
if (skill_meta) {
|
||||
|
@ -10,6 +10,7 @@ class SprintBuff : public Buff
|
||||
virtual void Deactivate() override;
|
||||
|
||||
private:
|
||||
void CollisionCheck();
|
||||
void ProcSkill();
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user