This commit is contained in:
aozhiwei 2021-03-23 19:13:58 +08:00
parent 5e61db6e30
commit cc22f58811
3 changed files with 45 additions and 22 deletions

View File

@ -196,7 +196,8 @@ enum SkillTarget_e
kST_EnemyGroup = 7,
kST_EnemyAndObject = 8,
kST_EnemyAndSelf = 9,
kST_SingleEnemyAndSelf = 10
kST_SingleEnemyAndSelf = 10,
kST_SpecDir = 11
};
enum VirtualWeapon_e

View File

@ -464,7 +464,7 @@ void Creature::ResetSkill()
{
curr_skill_ = nullptr;
curr_skill_phase = 0;
skill_dir = a8::Vec2();
skill_dir_ = a8::Vec2();
skill_target_pos_ = a8::Vec2();
skill_param1 = 0.0f;
playing_skill = false;
@ -499,29 +499,51 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
break;
case kSkill_Shot:
{
Entity* entity = room->GetEntityByUniId(skill_target_id_);
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt());
if (weapon_meta && entity) {
float target_distance = entity->GetPos().Distance(GetPos());
if (weapon_meta) {
MetaData::EquipUpgrade* weapon_upgrade_meta =
MetaMgr::Instance()->GetEquipUpgrade(weapon_meta->i->id());
MetaData::Equip* bullet_meta =
MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
if (bullet_meta && target_distance > 0.00001f) {
a8::Vec2 old_attack_dir = attack_dir;
attack_dir = entity->GetPos() - GetPos();
attack_dir.Normalize();
InternalShot
(
this,
weapon_meta,
weapon_upgrade_meta,
bullet_meta,
1,
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
target_distance,
false);
attack_dir = old_attack_dir;
if (CurrentSkill()->meta->i->skill_target() == kST_SpecDir) {
float target_distance = 5;
if (bullet_meta && target_distance > 0.00001f) {
a8::Vec2 old_attack_dir = attack_dir;
attack_dir = skill_dir_;
attack_dir.Normalize();
InternalShot
(
this,
weapon_meta,
weapon_upgrade_meta,
bullet_meta,
1,
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
target_distance,
false);
attack_dir = old_attack_dir;
}
} else {
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity) {
float target_distance = entity->GetPos().Distance(GetPos());
if (bullet_meta && target_distance > 0.00001f) {
a8::Vec2 old_attack_dir = attack_dir;
attack_dir = entity->GetPos() - GetPos();
attack_dir.Normalize();
InternalShot
(
this,
weapon_meta,
weapon_upgrade_meta,
bullet_meta,
1,
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
target_distance,
false);
attack_dir = old_attack_dir;
}
}
}
}
}
@ -637,7 +659,7 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
} else {
move_dir = entity->GetPos() - GetPos();
move_dir.Normalize();
skill_dir = move_dir;
skill_dir_ = move_dir;
skill_target_pos_ = GetPos() + move_dir * (target_distance - buff->meta->param3);
}
}

View File

@ -104,7 +104,7 @@ private:
std::array<Buff*, kBET_End> buff_effect_ = {};
std::list<Buff> buff_list_;
a8::Vec2 skill_dir;
a8::Vec2 skill_dir_;
float skill_param1 = 0;
bool playing_skill = false;
size_t curr_skill_phase = 0;