瞬间移动回血 ok

This commit is contained in:
aozhiwei 2022-07-29 18:50:57 +08:00
parent a8f5e21a8e
commit 15b449521a
7 changed files with 109 additions and 67 deletions

View File

@ -101,6 +101,9 @@ void AndroidAI::Update(int delta_time)
DefaultAi();
return;
}
if (hum->HasSpecMove()) {
hum->_UpdateSpecMove();
}
UpdateNewAI();
}

View File

@ -542,10 +542,36 @@ void Buff::ProcTurnOver()
return;
}
#endif
a8::Vec2 old_dir = owner->GetMoveDir();
a8::Vec2 old_pos = owner->GetPos();
float distance =
owner->HasBuffEffect(kBET_Car) ? phase->param1.GetDouble() * 1.5 : phase->param1.GetDouble();
#ifdef DEBUG
caster_.Get()->SendDebugMsg(a8::Format("ProcBecome currTimes:%d last_pos:%d,%d curr_pos:%d,%d",
{
skill->GetCurrTimes(),
owner->last_turn_over_pos.x,
owner->last_turn_over_pos.y,
owner->GetPos().x,
owner->GetPos().y
}));
#endif
if (phase->param2.GetInt() == 1) {
if (owner->turn_over_times % 2 == 1) {
distance = old_pos.Distance(owner->last_turn_over_pos);
if (distance > 0.01f) {
a8::Vec2 new_dir = owner->last_turn_over_pos - old_pos;
new_dir.Normalize();
owner->SetMoveDir(new_dir);
}
}
}
owner->_UpdateMove(distance);
owner->SetMoveDir(old_dir);
if (phase->param2.GetInt() == 1) {
++owner->turn_over_times;
owner->last_turn_over_pos = old_pos;
}
int moved_distance = (int)owner->GetPos().Distance(old_pos);
moved_distance = std::min(moved_distance, 200);
if (!meta->param1_int_list.empty() && moved_distance > 2) {

View File

@ -689,6 +689,11 @@ void Creature::OnBuffRemove(Buff& buff)
DecDisableMoveDirTimes();
}
break;
case kBET_BePull:
{
int i = 0;
}
break;
default:
{
}
@ -3079,3 +3084,70 @@ void Creature::SetBattleContext(std::shared_ptr<BattleDataContext> c)
{
battle_context_ = c;
}
bool Creature::HasSpecMove()
{
return GetBuffByEffectId(kBET_JumpTo) ||
GetBuffByEffectId(kBET_BePull);
}
void Creature::_UpdateSpecMove()
{
if (!HasSpecMove()) {
return;
}
bool move_end = false;
float target_distance = target_pos.Distance(GetPos());
if (target_distance <= 0.000001f) {
move_end = true;
} else {
a8::Vec2 old_move_dir = GetMoveDir();
a8::Vec2 move_dir = target_pos - GetPos();
move_dir.Normalize();
SetMoveDir(move_dir);
bool is_collision = false;
std::function<bool ()> old_on_move_collision = on_move_collision;
on_move_collision =
[&is_collision] () {
is_collision = true;
return false;
};
_UpdateMove(std::min((int)target_distance, (int)GetSpeed()));
on_move_collision = old_on_move_collision;
move_dir = old_move_dir;
target_distance = target_pos.Distance(GetPos());
if (is_collision || target_distance <= 1.0001f) {
move_end = true;
}
}
if (move_end) {
Buff* buff = GetBuffByEffectId(kBET_JumpTo);
if (buff) {
if (CurrentSkill() &&
buff->skill_meta == CurrentSkill()->meta &&
!CurrentSkill()->meta->phases.empty()) {
std::set<Creature*> target_list;
metatable::Skill* mutable_skill_meta = (metatable::Skill*)CurrentSkill()->meta->i;
float old_skill_distance = CurrentSkill()->meta->i->skill_distance();
mutable_skill_meta->set_skill_distance(CurrentSkill()->meta->phases[0].param1.GetDouble());
SelectSkillTargets(CurrentSkill(), GetPos(), target_list);
mutable_skill_meta->set_skill_distance(old_skill_distance);
TriggerBuff(CurrentSkill(), target_list, kBTT_SkillHit);
}
RemoveBuffByEffectId(kBET_JumpTo);
}
buff = GetBuffByEffectId(kBET_BePull);
if (buff) {
MetaData::Buff* new_buff = MetaMgr::Instance()->GetBuff(1039);
if (new_buff) {
AddBuff(this, new_buff, 1);
}
RemoveBuffByEffectId(kBET_BePull);
}
}
}

View File

@ -101,6 +101,9 @@ class Creature : public MoveableEntity
std::function<void ()> on_loading_bullet;
CreatureWeakPtr follow_target;
int turn_over_times = 0;
a8::Vec2 last_turn_over_pos;
Creature();
virtual ~Creature() override;
virtual void Initialize() override;
@ -204,6 +207,8 @@ class Creature : public MoveableEntity
void DecInventory(int slot_id, int num);
std::array<Inventory, IS_END>& GetInventoryData() { return inventory_; };
virtual void _UpdateMove(int speed) {};
bool HasSpecMove();
void _UpdateSpecMove();
void CheckSpecObject();
bool CollisonDetection();

View File

@ -33,6 +33,9 @@ void HeroAI::Update(int delta_time)
if (hero->dead) {
return;
}
if (hero->HasSpecMove()) {
hero->_UpdateSpecMove();
}
UpdateAI();
}

View File

@ -1806,71 +1806,6 @@ int Human::GetSkinConfigLv(int skin_id)
return itr != skin_configs.end() ? itr->second : 0;
}
bool Human::HasSpecMove()
{
return GetBuffByEffectId(kBET_JumpTo) ||
GetBuffByEffectId(kBET_BePull);
}
void Human::_UpdateSpecMove()
{
if (!HasSpecMove()) {
return;
}
bool move_end = false;
float target_distance = target_pos.Distance(GetPos());
if (target_distance <= 0.000001f) {
move_end = true;
} else {
a8::Vec2 old_move_dir = GetMoveDir();
a8::Vec2 move_dir = target_pos - GetPos();
move_dir.Normalize();
SetMoveDir(move_dir);
bool is_collision = false;
std::function<bool ()> old_on_move_collision = on_move_collision;
on_move_collision =
[&is_collision] () {
is_collision = true;
return false;
};
_UpdateMove(std::min((int)target_distance, (int)GetSpeed()));
on_move_collision = old_on_move_collision;
move_dir = old_move_dir;
target_distance = target_pos.Distance(GetPos());
if (is_collision || target_distance <= 1.0001f) {
move_end = true;
}
}
if (move_end) {
Buff* buff = GetBuffByEffectId(kBET_JumpTo);
if (buff) {
if (CurrentSkill() &&
buff->skill_meta == CurrentSkill()->meta &&
!CurrentSkill()->meta->phases.empty()) {
std::set<Creature*> target_list;
metatable::Skill* mutable_skill_meta = (metatable::Skill*)CurrentSkill()->meta->i;
float old_skill_distance = CurrentSkill()->meta->i->skill_distance();
mutable_skill_meta->set_skill_distance(CurrentSkill()->meta->phases[0].param1.GetDouble());
SelectSkillTargets(CurrentSkill(), GetPos(), target_list);
mutable_skill_meta->set_skill_distance(old_skill_distance);
TriggerBuff(CurrentSkill(), target_list, kBTT_SkillHit);
}
RemoveBuffByEffectId(kBET_JumpTo);
}
buff = GetBuffByEffectId(kBET_BePull);
if (buff) {
MetaData::Buff* new_buff = MetaMgr::Instance()->GetBuff(1039);
if (new_buff) {
AddBuff(this, new_buff, 1);
}
RemoveBuffByEffectId(kBET_BePull);
}
}
}
void Human::_UpdateMove(int speed)
{
if (HasBuffEffect(kBET_Vertigo)) {

View File

@ -326,8 +326,6 @@ class Human : public Creature
void OnEnable();
void OnDisable();
ObjectSyncFlags* GetObjectSyncFlags(int obj_uniid);
bool HasSpecMove();
void _UpdateSpecMove();
virtual void _UpdateMove(int speed) override;
Car* GetCar() { return car_; }
void SetCar(Car* car) { car_ = car; }