This commit is contained in:
aozhiwei 2021-03-18 13:37:22 +08:00
parent f7a468abe9
commit 091526aa32
6 changed files with 36 additions and 32 deletions

View File

@ -29,6 +29,15 @@ class Creature : public MoveableEntity
float GetBuffAttrRate(int attr_id); float GetBuffAttrRate(int attr_id);
void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list); void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list);
protected:
bool use_skill = false;
size_t curr_skill_phase = 0;
a8::Vec2 skill_dir;
float skill_param1 = 0;
bool playing_skill = false;
int skill_target_id_ = 0;
a8::Vec2 skill_target_pos_;
private: private:
virtual void AddBuffPostProc(Creature* caster, Buff* buff); virtual void AddBuffPostProc(Creature* caster, Buff* buff);
@ -40,4 +49,5 @@ private:
std::array<float, kHAT_End> buff_attr_rate_ = {}; std::array<float, kHAT_End> buff_attr_rate_ = {};
std::array<Buff*, kBET_End> buff_effect_ = {}; std::array<Buff*, kBET_End> buff_effect_ = {};
std::list<Buff> buff_list_; std::list<Buff> buff_list_;
}; };

View File

@ -1337,8 +1337,10 @@ void Human::DoJump()
} }
} }
void Human::DoSkill() void Human::DoSkill(int target_id, const a8::Vec2& target_pos)
{ {
skill_target_id_ = target_id;
skill_target_pos_ = target_pos;
if (action_type == AT_Reload || if (action_type == AT_Reload ||
action_type == AT_UseItem action_type == AT_UseItem
) { ) {
@ -1350,13 +1352,13 @@ void Human::DoSkill()
last_use_skill_frameno_ = room->GetFrameNo(); last_use_skill_frameno_ = room->GetFrameNo();
if (skill_meta_->i->skill_target() == kST_Self if (skill_meta_->i->skill_target() == kST_Self
) { ) {
skill_target_id = GetEntityUniId(); skill_target_id_ = GetEntityUniId();
} }
Entity* entity = room->GetEntityByUniId(skill_target_id); Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) { if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity; Human* hum = (Human*)entity;
std::set<Entity*> target_list; std::set<Entity*> target_list;
skill_target_pos = hum->GetPos(); skill_target_pos_ = hum->GetPos();
SelectSkillTargets(hum->GetPos(), target_list); SelectSkillTargets(hum->GetPos(), target_list);
TriggerBuff(target_list, kBTT_UseSkill); TriggerBuff(target_list, kBTT_UseSkill);
if (!skill_meta_->phases.empty() && skill_meta_->phases[0].time_offset <= 0) { if (!skill_meta_->phases.empty() && skill_meta_->phases[0].time_offset <= 0) {
@ -3143,25 +3145,25 @@ void Human::AddBuffPostProc(Creature* caster, Buff* buff)
break; break;
case kBET_JumpTo: case kBET_JumpTo:
{ {
Entity* entity = room->GetEntityByUniId(skill_target_id); Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity) { if (entity) {
float target_distance = entity->GetPos().Distance(GetPos()); float target_distance = entity->GetPos().Distance(GetPos());
if (target_distance <= 0.000001f) { if (target_distance <= 0.000001f) {
SetPos(entity->GetPos()); SetPos(entity->GetPos());
skill_target_pos = entity->GetPos(); skill_target_pos_ = entity->GetPos();
} else { } else {
if (target_distance <= buff->meta->param3) { if (target_distance <= buff->meta->param3) {
SetPos(entity->GetPos()); SetPos(entity->GetPos());
skill_target_pos = entity->GetPos(); skill_target_pos_ = entity->GetPos();
} else { } else {
move_dir = entity->GetPos() - GetPos(); move_dir = entity->GetPos() - GetPos();
move_dir.Normalize(); move_dir.Normalize();
skill_dir = move_dir; skill_dir = move_dir;
skill_target_pos = GetPos() + move_dir * (target_distance - buff->meta->param3); skill_target_pos_ = GetPos() + move_dir * (target_distance - buff->meta->param3);
} }
} }
} }
target_pos = skill_target_pos; target_pos = skill_target_pos_;
} }
break; break;
case kBET_Pull: case kBET_Pull:
@ -3463,7 +3465,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
break; break;
case kST_EnemySingle: case kST_EnemySingle:
{ {
Entity* entity = room->GetEntityByUniId(skill_target_id); Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) { if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity; Human* hum = (Human*)entity;
if (IsEnemy(hum)) { if (IsEnemy(hum)) {
@ -3513,7 +3515,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
break; break;
case kST_SingleEnemyAndSelf: case kST_SingleEnemyAndSelf:
{ {
Entity* entity = room->GetEntityByUniId(skill_target_id); Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) { if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity; Human* hum = (Human*)entity;
if (IsEnemy(hum)) { if (IsEnemy(hum)) {
@ -3542,7 +3544,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
break; break;
case kSkill_Shot: case kSkill_Shot:
{ {
Entity* entity = room->GetEntityByUniId(skill_target_id); Entity* entity = room->GetEntityByUniId(skill_target_id_);
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt()); MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt());
if (weapon_meta && entity) { if (weapon_meta && entity) {
float target_distance = entity->GetPos().Distance(GetPos()); float target_distance = entity->GetPos().Distance(GetPos());
@ -3864,7 +3866,7 @@ void Human::ResetSkill()
use_skill = false; use_skill = false;
curr_skill_phase = 0; curr_skill_phase = 0;
skill_dir = a8::Vec2(); skill_dir = a8::Vec2();
skill_target_pos = a8::Vec2(); skill_target_pos_ = a8::Vec2();
skill_param1 = 0.0f; skill_param1 = 0.0f;
playing_skill = false; playing_skill = false;
} }
@ -3940,20 +3942,20 @@ void Human::AddPassiveSkillBuff(MetaData::Skill* skill_meta)
return; return;
} }
MetaData::Skill* old_curr_skill = skill_meta_; MetaData::Skill* old_curr_skill = skill_meta_;
int old_skill_target_id = skill_target_id; int old_skill_target_id_ = skill_target_id_;
a8::Vec2 old_skill_target_pos = skill_target_pos; a8::Vec2 old_skill_target_pos_ = skill_target_pos_;
skill_meta_ = skill_meta; skill_meta_ = skill_meta;
skill_target_id = GetEntityUniId(); skill_target_id_ = GetEntityUniId();
skill_target_pos = GetPos(); skill_target_pos_ = GetPos();
std::set<Entity*> target_list; std::set<Entity*> target_list;
SelectSkillTargets(GetPos(), target_list); SelectSkillTargets(GetPos(), target_list);
TriggerBuff(target_list, kBTT_UseSkill); TriggerBuff(target_list, kBTT_UseSkill);
skill_meta_= old_curr_skill; skill_meta_= old_curr_skill;
skill_target_id = old_skill_target_id; skill_target_id_ = old_skill_target_id_;
skill_target_pos = old_skill_target_pos; skill_target_pos_ = old_skill_target_pos_;
} }
void Human::OnMetaChange() void Human::OnMetaChange()

View File

@ -138,13 +138,6 @@ class Human : public Creature
std::map<int, int> skin_configs; std::map<int, int> skin_configs;
std::map<int, int> spoils_items; std::map<int, int> spoils_items;
bool use_skill = false;
size_t curr_skill_phase = 0;
int skill_target_id = 0;
a8::Vec2 skill_dir;
a8::Vec2 skill_target_pos;
float skill_param1 = 0;
bool playing_skill = false;
xtimer_list* ad_timer_ = nullptr; xtimer_list* ad_timer_ = nullptr;
Human* last_human_target = nullptr; Human* last_human_target = nullptr;
@ -202,7 +195,7 @@ class Human : public Creature
bool HasNoDownedTeammate(); bool HasNoDownedTeammate();
bool CanUseSkill(); bool CanUseSkill();
void DoJump(); void DoJump();
void DoSkill(); void DoSkill(int target_id, const a8::Vec2& target_pos);
void DoGetOn(int obj_uniid); void DoGetOn(int obj_uniid);
void DoGetDown(); void DoGetDown();
void FindLocation(); void FindLocation();

View File

@ -393,7 +393,7 @@ void Player::UpdateUseSkill()
if (HasBuffEffect(kBET_Vertigo)) { if (HasBuffEffect(kBET_Vertigo)) {
return; return;
} }
DoSkill(); DoSkill(skill_target_id, a8::Vec2());
} }
void Player::Shot() void Player::Shot()
@ -1111,7 +1111,7 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
} }
if (msg.has_use_skill()) { if (msg.has_use_skill()) {
use_skill = msg.use_skill(); use_skill = msg.use_skill();
skill_target_id = msg.skill_target_id(); skill_target_id = msg.skill_target_id_();
} else { } else {
use_skill = false; use_skill = false;
} }

View File

@ -58,6 +58,7 @@ class Player : public Human
bool jump = false; bool jump = false;
bool use_skill = false; bool use_skill = false;
int skill_target_id = 0;
bool get_down = false; bool get_down = false;
int get_on = 0; int get_on = 0;

View File

@ -477,9 +477,7 @@ void ZombieModeAI::DoShot()
void ZombieModeAI::DoSkill() void ZombieModeAI::DoSkill()
{ {
Human* myself = (Human*)owner; Human* myself = (Human*)owner;
myself->skill_target_id = node_->target->GetEntityUniId(); myself->DoSkill(node_->target->GetEntityUniId(), node_->target->GetPos());
myself->skill_target_pos = node_->target->GetPos();
myself->DoSkill();
} }
int ZombieModeAI::GetAttackTimes() int ZombieModeAI::GetAttackTimes()