完成向心突擊

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()
{
if (a8::HasBitFlag(status, HS_Assaulting)) {
Buff* buff = GetBuffByEffectId(BET_Assault);
if (buff) {
return buff->meta->param2;
}
}
float speed = 0.0f;
if (downed) {
//倒地速度
@ -714,7 +720,7 @@ bool Human::HasNoDownedTeammate()
void Human::DoSkill()
{
if (skill_meta && GetSkillLeftTime() <= 0) {
if (skill_meta && GetSkillLeftTime() <= 0 && !a8::HasBitFlag(status, HS_Assaulting)) {
use_skill = false;
curr_skill_phase = 0;
skill_dir = a8::Vec2();
@ -1529,6 +1535,19 @@ void Human::ProcBuffEffect(Buff* buff)
);
}
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:
break;
}
@ -1722,6 +1741,58 @@ void Human::_UpdateMove(int speed)
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)
{
for (int i = 0; i < distance; ++i) {
@ -1974,6 +2045,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
switch (phase->func_id) {
case Skill_Jump:
{
#if 0
a8::Vec2 old_pos = pos;
pos = skill_target_pos;
if (IsCollisionInMapService()) {
@ -1998,6 +2070,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
room->grid_service.MoveHuman(this);
CheckGrass();
}
#endif
}
break;
case Skill_Shot:

View File

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

View File

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