This commit is contained in:
aozhiwei 2021-03-23 19:29:04 +08:00
parent cc22f58811
commit 1e75e2489c
5 changed files with 50 additions and 32 deletions

View File

@ -1,5 +1,7 @@
#include "precompile.h"
#include <float.h>
#include "creature.h"
#include "metamgr.h"
#include "room.h"
@ -414,7 +416,7 @@ bool Creature::CanUseSkill(int skill_id)
return skill->GetLeftTime() <= 0;
}
void Creature::DoSkill(int skill_id, int target_id, const a8::Vec2& target_pos)
void Creature::DoSkill(int skill_id, int target_id, const a8::Vec2& skill_dir, const a8::Vec2& target_pos)
{
DoSkillPreProc(skill_id, target_id, target_pos);
skill_target_id_ = target_id;
@ -429,19 +431,23 @@ void Creature::DoSkill(int skill_id, int target_id, const a8::Vec2& target_pos)
) {
skill_target_id_ = GetEntityUniId();
}
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) {
Creature* c = (Creature*)entity;
std::set<Entity*> target_list;
skill_target_pos_ = c->GetPos();
SelectSkillTargets(CurrentSkill(), c->GetPos(), target_list);
TriggerBuff(CurrentSkill(), target_list, kBTT_UseSkill);
if (!CurrentSkill()->meta->phases.empty() &&
CurrentSkill()->meta->phases[0].time_offset <= 0) {
UpdateSkill();
}
if (CurrentSkill()->meta->i->skill_target() == kST_SpecDir) {
UpdateSkill();
} else {
playing_skill = false;
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) {
Creature* c = (Creature*)entity;
std::set<Entity*> target_list;
skill_target_pos_ = c->GetPos();
SelectSkillTargets(CurrentSkill(), c->GetPos(), target_list);
TriggerBuff(CurrentSkill(), target_list, kBTT_UseSkill);
if (!CurrentSkill()->meta->phases.empty() &&
CurrentSkill()->meta->phases[0].time_offset <= 0) {
UpdateSkill();
}
} else {
playing_skill = false;
}
}
if (HasBuffEffect(kBET_Camouflage)) {
RemoveBuffByEffectId(kBET_Camouflage);
@ -506,22 +512,25 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
MetaData::Equip* bullet_meta =
MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
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;
if (std::abs(skill_dir_.x) > FLT_EPSILON ||
std::abs(skill_dir_.y) > FLT_EPSILON) {
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_);

View File

@ -60,7 +60,7 @@ class Creature : public MoveableEntity
const a8::Vec2& target_pos,
std::set<Entity*>& target_list);
virtual bool CanUseSkill(int skill_id);
void DoSkill(int skill_id, int target_id, const a8::Vec2& target_pos);
void DoSkill(int skill_id, int target_id, const a8::Vec2& skill_dir, const a8::Vec2& target_pos);
void ResetSkill();
Skill* CurrentSkill();
MetaData::SkillPhase* GetCurrSkillPhase();

View File

@ -393,7 +393,7 @@ void Player::UpdateUseSkill()
if (HasBuffEffect(kBET_Vertigo)) {
return;
}
DoSkill(use_skill_id, skill_target_id, a8::Vec2());
DoSkill(use_skill_id, skill_target_id, skill_dir, a8::Vec2());
use_skill = false;
}
@ -1122,6 +1122,14 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
use_skill = msg.use_skill();
use_skill_id = msg.skill_id();
skill_target_id = msg.skill_target_id();
if (std::abs(msg.skill_dir().x()) > FLT_EPSILON ||
std::abs(msg.skill_dir().y()) > FLT_EPSILON
) {
TypeConvert::FromPb(skill_dir, &msg.skill_dir());
skill_dir.Normalize();
} else {
skill_dir = a8::Vec2();
}
} else {
use_skill = false;
}

View File

@ -60,6 +60,7 @@ class Player : public Human
bool use_skill = false;
int use_skill_id = 0;
int skill_target_id = 0;
a8::Vec2 skill_dir;
bool get_down = false;
int get_on = 0;

View File

@ -479,7 +479,7 @@ void ZombieModeAI::DoShot()
void ZombieModeAI::DoSkill(int skill_id)
{
Human* myself = (Human*)owner;
myself->DoSkill(skill_id, node_->target->GetEntityUniId(), node_->target->GetPos());
myself->DoSkill(skill_id, node_->target->GetEntityUniId(), a8::Vec2(), node_->target->GetPos());
}
int ZombieModeAI::GetAttackTimes()