完成向心突擊

This commit is contained in:
aozhiwei 2019-07-17 16:40:43 +08:00
parent 0dff088dbd
commit a7756abb7e
3 changed files with 83 additions and 4 deletions

View File

@ -71,6 +71,12 @@ void Human::Initialize()
float Human::GetSpeed() float Human::GetSpeed()
{ {
if (a8::HasBitFlag(status, HS_Assaulting)) {
Buff* buff = GetBuffByEffectId(BET_Assault);
if (buff) {
return buff->meta->param2;
}
}
float speed = 0.0f; float speed = 0.0f;
if (downed) { if (downed) {
//倒地速度 //倒地速度
@ -714,7 +720,7 @@ bool Human::HasNoDownedTeammate()
void Human::DoSkill() void Human::DoSkill()
{ {
if (skill_meta && GetSkillLeftTime() <= 0) { if (skill_meta && GetSkillLeftTime() <= 0 && !a8::HasBitFlag(status, HS_Assaulting)) {
use_skill = false; use_skill = false;
curr_skill_phase = 0; curr_skill_phase = 0;
skill_dir = a8::Vec2(); skill_dir = a8::Vec2();
@ -1529,6 +1535,19 @@ void Human::ProcBuffEffect(Buff* buff)
); );
} }
break; break;
case BET_Assault:
{
a8::SetBitFlag(status, HS_Assaulting);
Entity* entity = room->GetEntityByUniId(skill_target_id);
if (entity) {
move_dir = entity->pos - pos;
move_dir.Normalize();
skill_target_pos = entity->pos;
skill_dir = skill_target_pos - pos;
skill_dir.Normalize();
}
}
break;
default: default:
break; break;
} }
@ -1722,6 +1741,58 @@ void Human::_UpdateMove(int speed)
CheckGrass(); CheckGrass();
} }
void Human::_UpdateAssaultMove()
{
Buff* buff = GetBuffByEffectId(BET_Assault);
if (!buff || (room->frame_no - buff->add_frameno) * FRAME_RATE_MS < buff->meta->param1) {
return;
}
bool move_end = false;
if (skill_target_pos.Distance(pos) <= 0.000001f) {
pos = skill_target_pos;
move_end = true;
} else {
a8::Vec2 tmp_move_dir = skill_target_pos - pos;
int speed = buff->meta->param2;
for (int i = 0; i < speed; ++i) {
pos = pos + tmp_move_dir;
if (skill_target_pos.Distance(pos) <= 0.000001f) {
pos = skill_target_pos;
move_end = true;
break;
}
}
}
CheckGrass();
if (move_end) {
if (!skill_meta->phases.empty()) {
MetaData::SkillPhase* phase = &skill_meta->phases[0];
std::set<Entity*> target_list;
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < hum->GetRadius()) {
if (!hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(phase->param1.GetDouble(), entity_uniid, name, 0);
target_list.insert(hum);
}
a8::Vec2 pull_dir = skill_dir;
if (std::abs(pull_dir.x) > FLT_EPSILON ||
std::abs(pull_dir.y) > FLT_EPSILON) {
pull_dir.Normalize();
hum->PullHuman(pull_dir, phase->param2.GetDouble());
}
}
}
}
TriggerBuff(target_list, BTT_SkillHit);
room->frame_event.AddExplosion(0, pos, 2);
room->grid_service.MoveHuman(this);
}
RemoveBuff(buff->meta->i->buff_id());
a8::UnSetBitFlag(status, HS_Assaulting);
}
}
void Human::PullHuman(const a8::Vec2& pull_dir, float distance) void Human::PullHuman(const a8::Vec2& pull_dir, float distance)
{ {
for (int i = 0; i < distance; ++i) { for (int i = 0; i < distance; ++i) {
@ -1974,6 +2045,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
switch (phase->func_id) { switch (phase->func_id) {
case Skill_Jump: case Skill_Jump:
{ {
#if 0
a8::Vec2 old_pos = pos; a8::Vec2 old_pos = pos;
pos = skill_target_pos; pos = skill_target_pos;
if (IsCollisionInMapService()) { if (IsCollisionInMapService()) {
@ -1998,6 +2070,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
room->grid_service.MoveHuman(this); room->grid_service.MoveHuman(this);
CheckGrass(); CheckGrass();
} }
#endif
} }
break; break;
case Skill_Shot: case Skill_Shot:

View File

@ -18,6 +18,7 @@ namespace MetaData
enum HumanStatus enum HumanStatus
{ {
HS_InGrass = 1, HS_InGrass = 1,
HS_Assaulting = 2,
HS_End HS_End
}; };
@ -213,6 +214,7 @@ class Human : public Entity
protected: protected:
void _UpdateMove(int speed); void _UpdateMove(int speed);
void _UpdateAssaultMove();
void PullHuman(const a8::Vec2& pull_dir, float distance); void PullHuman(const a8::Vec2& pull_dir, float distance);
private: private:

View File

@ -53,8 +53,12 @@ void Player::Update(int delta_time)
if (poisoning) { if (poisoning) {
poisoning_time += delta_time; poisoning_time += delta_time;
} }
if (moving) { if (a8::HasBitFlag(status, HS_Assaulting)) {
UpdateMove(); _UpdateAssaultMove();
} else {
if (moving) {
UpdateMove();
}
} }
if (room->frame_no % 2 == 0) { if (room->frame_no % 2 == 0) {
if (shot_start || shot_hold) { if (shot_start || shot_hold) {
@ -372,7 +376,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg) void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
{ {
moving = false; moving = false;
if (msg.has_move_dir()) { if (msg.has_move_dir() && !a8::HasBitFlag(status, HS_Assaulting)) {
if (std::abs(msg.move_dir().x()) > FLT_EPSILON || if (std::abs(msg.move_dir().x()) > FLT_EPSILON ||
std::abs(msg.move_dir().y()) > FLT_EPSILON std::abs(msg.move_dir().y()) > FLT_EPSILON
) { ) {