重构attack_dir
This commit is contained in:
parent
ccf89f53d0
commit
e0c39849e5
@ -144,7 +144,7 @@ void AndroidNewAI::ChangeToStateOldAI(AndroidState_e to_state)
|
|||||||
move_dir.Rotate(a8::RandAngle());
|
move_dir.Rotate(a8::RandAngle());
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -208,7 +208,7 @@ void AndroidNewAI::DoAttackOldAI()
|
|||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
shot_dir.Normalize();
|
shot_dir.Normalize();
|
||||||
shot_dir.Rotate((rand() % 10) / 180.0f);
|
shot_dir.Rotate((rand() % 10) / 180.0f);
|
||||||
sender->attack_dir = shot_dir;
|
sender->SetAttackDir(shot_dir);
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ void AndroidNewAI::UpdateNewBieNpc()
|
|||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
}
|
}
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
if (hum->GetCurrWeapon()->weapon_idx != 0) {
|
if (hum->GetCurrWeapon()->weapon_idx != 0) {
|
||||||
hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo;
|
hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo;
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ void AndroidNewAI::UpdateNewBieNpc()
|
|||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
shot_dir.Normalize();
|
shot_dir.Normalize();
|
||||||
shot_dir.Rotate((rand() % 10) / 180.0f);
|
shot_dir.Rotate((rand() % 10) / 180.0f);
|
||||||
sender->attack_dir = shot_dir;
|
sender->SetAttackDir(shot_dir);
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ void AndroidNewAI::UpdateLastNpc()
|
|||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
}
|
}
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
if (hum->GetCurrWeapon()->weapon_idx != 0) {
|
if (hum->GetCurrWeapon()->weapon_idx != 0) {
|
||||||
hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo * 2;
|
hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo * 2;
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ void AndroidNewAI::UpdateLastNpc()
|
|||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
shot_dir.Normalize();
|
shot_dir.Normalize();
|
||||||
shot_dir.Rotate((rand() % 10) / 180.0f);
|
shot_dir.Rotate((rand() % 10) / 180.0f);
|
||||||
sender->attack_dir = shot_dir;
|
sender->SetAttackDir(shot_dir);
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic()
|
|||||||
a8::Vec2 move_dir = target->GetPos() - hum->GetPos();
|
a8::Vec2 move_dir = target->GetPos() - hum->GetPos();
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
speed *= 0.7;
|
speed *= 0.7;
|
||||||
for (int i = 0; i < speed; ++i) {
|
for (int i = 0; i < speed; ++i) {
|
||||||
hum->SetPos(hum->GetPos() + hum->GetMoveDir());
|
hum->SetPos(hum->GetPos() + hum->GetMoveDir());
|
||||||
@ -401,7 +401,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic()
|
|||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
shot_dir.Normalize();
|
shot_dir.Normalize();
|
||||||
shot_dir.Rotate((rand() % 10) / 180.0f);
|
shot_dir.Rotate((rand() % 10) / 180.0f);
|
||||||
sender->attack_dir = shot_dir;
|
sender->SetAttackDir(shot_dir);
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
}
|
}
|
||||||
@ -678,7 +678,7 @@ void AndroidNewAI::ChangeToStateNewAI(AndroidStateEx_e to_state)
|
|||||||
move_dir.Rotate(a8::RandAngle());
|
move_dir.Rotate(a8::RandAngle());
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
if (node_.param1 <= 1) {
|
if (node_.param1 <= 1) {
|
||||||
moving_ = false;
|
moving_ = false;
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ void AndroidNewAI::ChangeToStateNewAI(AndroidStateEx_e to_state)
|
|||||||
a8::Vec2 move_dir = node_.target.Get()->GetPos() - hum->GetPos();
|
a8::Vec2 move_dir = node_.target.Get()->GetPos() - hum->GetPos();
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -755,11 +755,11 @@ void AndroidNewAI::DoShotNewAI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 shot_dir = myself->attack_dir;
|
a8::Vec2 shot_dir = myself->GetAttackDir();
|
||||||
if (node_.total_shot_times >= node_.next_total_shot_times) {
|
if (node_.total_shot_times >= node_.next_total_shot_times) {
|
||||||
shot_dir = node_.target.Get()->GetPos() - myself->GetPos();
|
shot_dir = node_.target.Get()->GetPos() - myself->GetPos();
|
||||||
node_.next_total_shot_times += 7 + (rand() % 6);
|
node_.next_total_shot_times += 7 + (rand() % 6);
|
||||||
myself->attack_dir = shot_dir;
|
myself->SetAttackDir(shot_dir);
|
||||||
}
|
}
|
||||||
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
@ -773,10 +773,10 @@ void AndroidNewAI::DoShotNewAI()
|
|||||||
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::Vec2 old_attack_dir = myself->attack_dir;
|
a8::Vec2 old_attack_dir = myself->GetAttackDir();
|
||||||
myself->attack_dir = shot_dir;
|
myself->SetAttackDir(shot_dir);
|
||||||
myself->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
myself->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
myself->attack_dir = old_attack_dir;
|
myself->SetAttackDir(old_attack_dir);
|
||||||
if (shot_ok) {
|
if (shot_ok) {
|
||||||
if (node_.shot_times <= 0) {
|
if (node_.shot_times <= 0) {
|
||||||
node_.start_shot_frameno = myself->room->GetFrameNo();
|
node_.start_shot_frameno = myself->room->GetFrameNo();
|
||||||
|
@ -36,7 +36,7 @@ void InternalShot(Creature* c,
|
|||||||
}
|
}
|
||||||
for (auto& tuple : weapon_meta->bullet_born_offset) {
|
for (auto& tuple : weapon_meta->bullet_born_offset) {
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
bullet_born_offset.Rotate(c->attack_dir.CalcAngle(a8::Vec2::UP));
|
bullet_born_offset.Rotate(c->GetAttackDir().CalcAngle(a8::Vec2::UP));
|
||||||
a8::Vec2 bullet_born_pos = c->GetPos() + bullet_born_offset;
|
a8::Vec2 bullet_born_pos = c->GetPos() + bullet_born_offset;
|
||||||
if (c->room->OverBorder(bullet_born_pos, 0.0f)) {
|
if (c->room->OverBorder(bullet_born_pos, 0.0f)) {
|
||||||
return;
|
return;
|
||||||
@ -47,9 +47,9 @@ void InternalShot(Creature* c,
|
|||||||
}
|
}
|
||||||
for (auto& tuple : weapon_meta->bullet_born_offset) {
|
for (auto& tuple : weapon_meta->bullet_born_offset) {
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
bullet_born_offset.Rotate(c->attack_dir.CalcAngle(a8::Vec2::UP));
|
bullet_born_offset.Rotate(c->GetAttackDir().CalcAngle(a8::Vec2::UP));
|
||||||
a8::Vec2 bullet_born_pos = c->GetPos() + c->shoot_offset + bullet_born_offset;
|
a8::Vec2 bullet_born_pos = c->GetPos() + c->shoot_offset + bullet_born_offset;
|
||||||
a8::Vec2 bullet_dir = c->attack_dir;
|
a8::Vec2 bullet_dir = c->GetAttackDir();
|
||||||
float bullet_angle = std::get<2>(tuple);
|
float bullet_angle = std::get<2>(tuple);
|
||||||
if (weapon_meta->i->bullet_angle() >= 0.10f) {
|
if (weapon_meta->i->bullet_angle() >= 0.10f) {
|
||||||
int angle = (int)weapon_meta->i->bullet_angle() * 1000;
|
int angle = (int)weapon_meta->i->bullet_angle() * 1000;
|
||||||
@ -80,7 +80,7 @@ void InternalShot(Creature* c,
|
|||||||
if (weapon_meta->i->recoil_force() > 0.000001) {
|
if (weapon_meta->i->recoil_force() > 0.000001) {
|
||||||
a8::Vec2 old_move_dir = c->GetMoveDir();
|
a8::Vec2 old_move_dir = c->GetMoveDir();
|
||||||
c->MustBeAddBuff(c, kRecoilBuffId);
|
c->MustBeAddBuff(c, kRecoilBuffId);
|
||||||
c->SetMoveDir(c->attack_dir * -1);
|
c->SetMoveDir(c->GetAttackDir() * -1);
|
||||||
c->_UpdateMove(weapon_meta->i->recoil_force());
|
c->_UpdateMove(weapon_meta->i->recoil_force());
|
||||||
c->SetMoveDir(old_move_dir);
|
c->SetMoveDir(old_move_dir);
|
||||||
}
|
}
|
||||||
@ -630,9 +630,10 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
|
|||||||
std::abs(skill_dir_.y) > FLT_EPSILON) {
|
std::abs(skill_dir_.y) > FLT_EPSILON) {
|
||||||
float target_distance = 5;
|
float target_distance = 5;
|
||||||
if (bullet_meta && target_distance > 0.00001f) {
|
if (bullet_meta && target_distance > 0.00001f) {
|
||||||
a8::Vec2 old_attack_dir = attack_dir;
|
a8::Vec2 old_attack_dir = GetAttackDir();
|
||||||
attack_dir = skill_dir_;
|
a8::Vec2 attack_dir = skill_dir_;
|
||||||
attack_dir.Normalize();
|
attack_dir.Normalize();
|
||||||
|
SetAttackDir(attack_dir);
|
||||||
InternalShot
|
InternalShot
|
||||||
(
|
(
|
||||||
this,
|
this,
|
||||||
@ -643,7 +644,7 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
|
|||||||
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
|
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
|
||||||
target_distance,
|
target_distance,
|
||||||
false);
|
false);
|
||||||
attack_dir = old_attack_dir;
|
SetAttackDir(old_attack_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -651,8 +652,8 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
|
|||||||
if (entity) {
|
if (entity) {
|
||||||
float target_distance = entity->GetPos().Distance(GetPos());
|
float target_distance = entity->GetPos().Distance(GetPos());
|
||||||
if (bullet_meta && target_distance > 0.00001f) {
|
if (bullet_meta && target_distance > 0.00001f) {
|
||||||
a8::Vec2 old_attack_dir = attack_dir;
|
a8::Vec2 old_attack_dir = GetAttackDir();
|
||||||
attack_dir = entity->GetPos() - GetPos();
|
a8::Vec2 attack_dir = entity->GetPos() - GetPos();
|
||||||
attack_dir.Normalize();
|
attack_dir.Normalize();
|
||||||
InternalShot
|
InternalShot
|
||||||
(
|
(
|
||||||
@ -664,7 +665,7 @@ void Creature::ProcSkillPhase(MetaData::SkillPhase* phase)
|
|||||||
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
|
CurrentSkill() ? CurrentSkill()->meta->i->skill_id() : 0,
|
||||||
target_distance,
|
target_distance,
|
||||||
false);
|
false);
|
||||||
attack_dir = old_attack_dir;
|
SetAttackDir(old_attack_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ class Creature : public MoveableEntity
|
|||||||
bool aiming = false;
|
bool aiming = false;
|
||||||
std::list<int> aiming_buffs;
|
std::list<int> aiming_buffs;
|
||||||
long long aiming_frameno = 0;
|
long long aiming_frameno = 0;
|
||||||
a8::Vec2 attack_dir;
|
|
||||||
a8::Vec2 shoot_offset;
|
a8::Vec2 shoot_offset;
|
||||||
HumanAbility ability;
|
HumanAbility ability;
|
||||||
a8::Vec2 target_pos;
|
a8::Vec2 target_pos;
|
||||||
|
@ -309,7 +309,7 @@ void HeroAI::ChangeToStateAI(HeroState_e to_state)
|
|||||||
move_dir.Rotate(a8::RandAngle());
|
move_dir.Rotate(a8::RandAngle());
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hero->SetMoveDir(move_dir);
|
hero->SetMoveDir(move_dir);
|
||||||
hero->attack_dir = hero->GetMoveDir();
|
hero->SetAttackDir(hero->GetMoveDir());
|
||||||
if (node_.param1 <= 1) {
|
if (node_.param1 <= 1) {
|
||||||
moving_ = false;
|
moving_ = false;
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ void HeroAI::ChangeToStateAI(HeroState_e to_state)
|
|||||||
a8::Vec2 move_dir = node_.target.Get()->GetPos() - hero->GetPos();
|
a8::Vec2 move_dir = node_.target.Get()->GetPos() - hero->GetPos();
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hero->SetMoveDir(move_dir);
|
hero->SetMoveDir(move_dir);
|
||||||
hero->attack_dir = hero->GetMoveDir();
|
hero->SetAttackDir(hero->GetMoveDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -337,7 +337,7 @@ void HeroAI::ChangeToStateAI(HeroState_e to_state)
|
|||||||
a8::Vec2 move_dir = target_pos - hero->GetPos();
|
a8::Vec2 move_dir = target_pos - hero->GetPos();
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hero->SetMoveDir(move_dir);
|
hero->SetMoveDir(move_dir);
|
||||||
hero->attack_dir = hero->GetMoveDir();
|
hero->SetAttackDir(hero->GetMoveDir());
|
||||||
node_.target_pos = target_pos;
|
node_.target_pos = target_pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,11 +402,11 @@ void HeroAI::DoShotAI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 shot_dir = myself->attack_dir;
|
a8::Vec2 shot_dir = myself->GetAttackDir();
|
||||||
if (node_.total_shot_times >= node_.next_total_shot_times) {
|
if (node_.total_shot_times >= node_.next_total_shot_times) {
|
||||||
shot_dir = node_.target.Get()->GetPos() - myself->GetPos();
|
shot_dir = node_.target.Get()->GetPos() - myself->GetPos();
|
||||||
node_.next_total_shot_times += 7 + (rand() % 6);
|
node_.next_total_shot_times += 7 + (rand() % 6);
|
||||||
myself->attack_dir = shot_dir;
|
myself->SetAttackDir(shot_dir);
|
||||||
}
|
}
|
||||||
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
@ -420,10 +420,10 @@ void HeroAI::DoShotAI()
|
|||||||
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::Vec2 old_attack_dir = myself->attack_dir;
|
a8::Vec2 old_attack_dir = myself->GetAttackDir();
|
||||||
myself->attack_dir = shot_dir;
|
myself->SetAttackDir(shot_dir);
|
||||||
myself->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
myself->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
myself->attack_dir = old_attack_dir;
|
myself->SetAttackDir(old_attack_dir);
|
||||||
if (shot_ok) {
|
if (shot_ok) {
|
||||||
if (node_.shot_times <= 0) {
|
if (node_.shot_times <= 0) {
|
||||||
node_.start_shot_frameno = myself->room->GetFrameNo();
|
node_.start_shot_frameno = myself->room->GetFrameNo();
|
||||||
|
@ -121,7 +121,7 @@ void Human::FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data
|
|||||||
p->set_obj_uniid(GetEntityUniId());
|
p->set_obj_uniid(GetEntityUniId());
|
||||||
p->set_speed(GetSpeed() * SERVER_FRAME_RATE);
|
p->set_speed(GetSpeed() * SERVER_FRAME_RATE);
|
||||||
TypeConvert::ToPb(GetPos(), p->mutable_pos());
|
TypeConvert::ToPb(GetPos(), p->mutable_pos());
|
||||||
TypeConvert::ToPb(attack_dir, p->mutable_dir());
|
TypeConvert::ToPb(GetAttackDir(), p->mutable_dir());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data)
|
void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data)
|
||||||
@ -129,7 +129,7 @@ void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data
|
|||||||
cs::MFPlayerFull* p = full_data;
|
cs::MFPlayerFull* p = full_data;
|
||||||
p->set_obj_uniid(GetEntityUniId());
|
p->set_obj_uniid(GetEntityUniId());
|
||||||
TypeConvert::ToPb(GetPos(), p->mutable_pos());
|
TypeConvert::ToPb(GetPos(), p->mutable_pos());
|
||||||
TypeConvert::ToPb(attack_dir, p->mutable_dir());
|
TypeConvert::ToPb(GetAttackDir(), p->mutable_dir());
|
||||||
|
|
||||||
p->set_health(GetHP());
|
p->set_health(GetHP());
|
||||||
p->set_max_health(GetMaxHP());
|
p->set_max_health(GetMaxHP());
|
||||||
@ -154,7 +154,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data
|
|||||||
cs::MFPlayerFull* p = full_data->mutable_union_obj_1();
|
cs::MFPlayerFull* p = full_data->mutable_union_obj_1();
|
||||||
p->set_obj_uniid(GetEntityUniId());
|
p->set_obj_uniid(GetEntityUniId());
|
||||||
TypeConvert::ToPb(GetPos(), p->mutable_pos());
|
TypeConvert::ToPb(GetPos(), p->mutable_pos());
|
||||||
TypeConvert::ToPb(attack_dir, p->mutable_dir());
|
TypeConvert::ToPb(GetAttackDir(), p->mutable_dir());
|
||||||
|
|
||||||
p->set_health(GetHP());
|
p->set_health(GetHP());
|
||||||
p->set_max_health(GetMaxHP());
|
p->set_max_health(GetMaxHP());
|
||||||
@ -372,7 +372,7 @@ void Human::FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over)
|
|||||||
team_data->set_player_id(GetEntityUniId());
|
team_data->set_player_id(GetEntityUniId());
|
||||||
if (is_game_over || !real_dead || room->GetFrameNo() - GetRealDeadFrameNo(room) < 4) {
|
if (is_game_over || !real_dead || room->GetFrameNo() - GetRealDeadFrameNo(room) < 4) {
|
||||||
TypeConvert::ToPb(GetPos(), team_data->mutable_pos());
|
TypeConvert::ToPb(GetPos(), team_data->mutable_pos());
|
||||||
TypeConvert::ToPb(attack_dir, team_data->mutable_dir());
|
TypeConvert::ToPb(GetAttackDir(), team_data->mutable_dir());
|
||||||
team_data->set_health(GetHP());
|
team_data->set_health(GetHP());
|
||||||
team_data->set_max_health(GetMaxHP());
|
team_data->set_max_health(GetMaxHP());
|
||||||
team_data->set_dead(dead);
|
team_data->set_dead(dead);
|
||||||
@ -415,7 +415,7 @@ void Human::FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::CarShot(a8::Vec2& target_dir)
|
void Human::CarShot(const a8::Vec2& target_dir)
|
||||||
{
|
{
|
||||||
if (!second_weapon.meta) {
|
if (!second_weapon.meta) {
|
||||||
return;
|
return;
|
||||||
|
@ -154,7 +154,7 @@ class Human : public Creature
|
|||||||
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
||||||
long long GetRealDeadFrameNo(Room* room);
|
long long GetRealDeadFrameNo(Room* room);
|
||||||
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
|
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
|
||||||
void CarShot(a8::Vec2& target_dir);
|
void CarShot(const a8::Vec2& target_dir);
|
||||||
virtual void RecalcSelfCollider() override;
|
virtual void RecalcSelfCollider() override;
|
||||||
bool IsCollisionInMapService();
|
bool IsCollisionInMapService();
|
||||||
void FindPathInMapService();
|
void FindPathInMapService();
|
||||||
|
@ -26,10 +26,13 @@ class MoveableEntity : public RoomEntity
|
|||||||
virtual void SyncAroundPlayers(const char* file, int line, const char* func);
|
virtual void SyncAroundPlayers(const char* file, int line, const char* func);
|
||||||
virtual const a8::Vec2& GetMoveDir() { return move_dir_; };
|
virtual const a8::Vec2& GetMoveDir() { return move_dir_; };
|
||||||
virtual void SetMoveDir(const a8::Vec2& move_dir) { move_dir_ = move_dir; };
|
virtual void SetMoveDir(const a8::Vec2& move_dir) { move_dir_ = move_dir; };
|
||||||
|
virtual const a8::Vec2& GetAttackDir() { return attack_dir_; };
|
||||||
|
virtual void SetAttackDir(const a8::Vec2& attack_dir) { attack_dir_ = attack_dir; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int updated_times_ = 0;
|
int updated_times_ = 0;
|
||||||
a8::Vec2 move_dir_;
|
a8::Vec2 move_dir_;
|
||||||
|
a8::Vec2 attack_dir_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<GridCell*> grid_list_;
|
std::set<GridCell*> grid_list_;
|
||||||
|
@ -192,11 +192,11 @@ void Player::UpdateShot()
|
|||||||
}
|
}
|
||||||
if (GetCar() && GetCar()->IsDriver(this)) {
|
if (GetCar() && GetCar()->IsDriver(this)) {
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 target_dir = attack_dir;
|
a8::Vec2 target_dir = GetAttackDir();
|
||||||
GetCar()->attack_dir = attack_dir;
|
GetCar()->SetAttackDir(GetAttackDir());
|
||||||
GetCar()->Shot(target_dir, shot_ok, fly_distance);
|
GetCar()->Shot(target_dir, shot_ok, fly_distance);
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
GetCar()->SetMoveDir(attack_dir);
|
GetCar()->SetMoveDir(GetAttackDir());
|
||||||
}
|
}
|
||||||
shot_start = false;
|
shot_start = false;
|
||||||
return;
|
return;
|
||||||
@ -424,12 +424,12 @@ void Player::UpdateUseSkill()
|
|||||||
void Player::Shot()
|
void Player::Shot()
|
||||||
{
|
{
|
||||||
if (second_weapon.meta) {
|
if (second_weapon.meta) {
|
||||||
CarShot(attack_dir);
|
CarShot(GetAttackDir());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 target_dir = attack_dir;
|
a8::Vec2 target_dir = GetAttackDir();
|
||||||
Creature::Shot(target_dir, shot_ok, fly_distance);
|
Creature::Shot(target_dir, shot_ok, fly_distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,12 +1024,16 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
|||||||
std::abs(msg.attack_dir().y()) > 0.00001f
|
std::abs(msg.attack_dir().y()) > 0.00001f
|
||||||
)
|
)
|
||||||
){
|
){
|
||||||
TypeConvert::FromPb(attack_dir, &msg.attack_dir());
|
if (!HasBuffEffect(kBET_Vertigo)) {
|
||||||
attack_dir.Normalize();
|
a8::Vec2 attack_dir;
|
||||||
|
TypeConvert::FromPb(attack_dir, &msg.attack_dir());
|
||||||
|
attack_dir.Normalize();
|
||||||
|
SetAttackDir(attack_dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (moving) {
|
if (moving) {
|
||||||
attack_dir = GetMoveDir();
|
SetAttackDir(GetMoveDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (moving) {
|
if (moving) {
|
||||||
|
@ -227,10 +227,11 @@ void Room::AddPlayer(Player* hum)
|
|||||||
} else {
|
} else {
|
||||||
hum->SetPos(hum->born_point->RandPoint());
|
hum->SetPos(hum->born_point->RandPoint());
|
||||||
}
|
}
|
||||||
hum->attack_dir = hum->GetPos();
|
a8::Vec2 attack_dir = hum->GetPos();
|
||||||
hum->attack_dir.Normalize();
|
attack_dir.Normalize();
|
||||||
hum->attack_dir.Rotate(a8::RandAngle());
|
attack_dir.Rotate(a8::RandAngle());
|
||||||
hum->SetMoveDir(hum->attack_dir);
|
hum->SetAttackDir(attack_dir);
|
||||||
|
hum->SetMoveDir(attack_dir);
|
||||||
|
|
||||||
hum->room = this;
|
hum->room = this;
|
||||||
hum->join_frameno = GetFrameNo();
|
hum->join_frameno = GetFrameNo();
|
||||||
@ -339,10 +340,11 @@ void Room::CreateAndroid(int robot_num)
|
|||||||
} else {
|
} else {
|
||||||
hum->SetPos(hum->born_point->RandPoint());
|
hum->SetPos(hum->born_point->RandPoint());
|
||||||
}
|
}
|
||||||
hum->attack_dir = hum->GetPos();
|
a8::Vec2 attack_dir = hum->GetPos();
|
||||||
hum->attack_dir.Normalize();
|
attack_dir.Normalize();
|
||||||
hum->attack_dir.Rotate(a8::RandAngle());
|
attack_dir.Rotate(a8::RandAngle());
|
||||||
hum->SetMoveDir(hum->attack_dir);
|
hum->SetAttackDir(attack_dir);
|
||||||
|
hum->SetMoveDir(attack_dir);
|
||||||
hum->room = this;
|
hum->room = this;
|
||||||
hum->Initialize();
|
hum->Initialize();
|
||||||
AddToEntityHash(hum);
|
AddToEntityHash(hum);
|
||||||
@ -611,7 +613,7 @@ Hero* Room::CreateHero(Creature* master,
|
|||||||
hero->room = this;
|
hero->room = this;
|
||||||
hero->SetPos(pos);
|
hero->SetPos(pos);
|
||||||
hero->SetMoveDir(dir);
|
hero->SetMoveDir(dir);
|
||||||
hero->attack_dir = dir;
|
hero->SetAttackDir(dir);
|
||||||
hero->team_id = team_id;
|
hero->team_id = team_id;
|
||||||
hero->Initialize();
|
hero->Initialize();
|
||||||
hero->SetAiLevel(7);
|
hero->SetAiLevel(7);
|
||||||
@ -1791,7 +1793,7 @@ void Room::ShuaPlane()
|
|||||||
pair.second->MustBeAddBuff(pair.second, FLY_BUFFID);
|
pair.second->MustBeAddBuff(pair.second, FLY_BUFFID);
|
||||||
pair.second->ResetAllSkillCd();
|
pair.second->ResetAllSkillCd();
|
||||||
pair.second->SetPos(plane.curr_pos);
|
pair.second->SetPos(plane.curr_pos);
|
||||||
pair.second->attack_dir = plane.dir;
|
pair.second->SetAttackDir(plane.dir);
|
||||||
pair.second->SetMoveDir(plane.dir);
|
pair.second->SetMoveDir(plane.dir);
|
||||||
grid_service->MoveCreature(pair.second);
|
grid_service->MoveCreature(pair.second);
|
||||||
pair.second->AddToNewObjects(pair.second);
|
pair.second->AddToNewObjects(pair.second);
|
||||||
@ -3630,7 +3632,7 @@ void Room::FillObjectPositions(Human* hum, cs::SMUpdate& msg)
|
|||||||
auto p = msg.add_object_positions();
|
auto p = msg.add_object_positions();
|
||||||
p->set_obj_uniid(pair.second->GetEntityUniId());
|
p->set_obj_uniid(pair.second->GetEntityUniId());
|
||||||
TypeConvert::ToPb(pair.second->GetPos(), p->mutable_pos());
|
TypeConvert::ToPb(pair.second->GetPos(), p->mutable_pos());
|
||||||
TypeConvert::ToPb(pair.second->attack_dir, p->mutable_dir());
|
TypeConvert::ToPb(pair.second->GetAttackDir(), p->mutable_dir());
|
||||||
p->set_race((int)pair.second->GetRace());
|
p->set_race((int)pair.second->GetRace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ void ZombieModeAI::ChangeToState(ZombieState_e to_state)
|
|||||||
move_dir.Rotate(a8::RandAngle());
|
move_dir.Rotate(a8::RandAngle());
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
if (node_->param1 <= 1) {
|
if (node_->param1 <= 1) {
|
||||||
node_->moving = false;
|
node_->moving = false;
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ void ZombieModeAI::ChangeToState(ZombieState_e to_state)
|
|||||||
a8::Vec2 move_dir = node_->target.Get()->GetPos() - hum->GetPos();
|
a8::Vec2 move_dir = node_->target.Get()->GetPos() - hum->GetPos();
|
||||||
move_dir.Normalize();
|
move_dir.Normalize();
|
||||||
hum->SetMoveDir(move_dir);
|
hum->SetMoveDir(move_dir);
|
||||||
hum->attack_dir = hum->GetMoveDir();
|
hum->SetAttackDir(hum->GetMoveDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -437,11 +437,11 @@ void ZombieModeAI::DoShot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 shot_dir = myself->attack_dir;
|
a8::Vec2 shot_dir = myself->GetAttackDir();
|
||||||
if (node_->total_shot_times >= node_->next_total_shot_times) {
|
if (node_->total_shot_times >= node_->next_total_shot_times) {
|
||||||
shot_dir = node_->target.Get()->GetPos() - myself->GetPos();
|
shot_dir = node_->target.Get()->GetPos() - myself->GetPos();
|
||||||
node_->next_total_shot_times += 7 + (rand() % 6);
|
node_->next_total_shot_times += 7 + (rand() % 6);
|
||||||
myself->attack_dir = shot_dir;
|
myself->SetAttackDir(shot_dir);
|
||||||
}
|
}
|
||||||
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
||||||
std::abs(shot_dir.y) > FLT_EPSILON) {
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
@ -455,10 +455,10 @@ void ZombieModeAI::DoShot()
|
|||||||
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
shot_dir.Rotate(shot_offset_angle / -180.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::Vec2 old_attack_dir = myself->attack_dir;
|
a8::Vec2 old_attack_dir = myself->GetAttackDir();
|
||||||
myself->attack_dir = shot_dir;
|
myself->SetAttackDir(shot_dir);
|
||||||
myself->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
myself->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE);
|
||||||
myself->attack_dir = old_attack_dir;
|
myself->SetAttackDir(old_attack_dir);
|
||||||
if (shot_ok) {
|
if (shot_ok) {
|
||||||
if (node_->shot_times <= 0) {
|
if (node_->shot_times <= 0) {
|
||||||
node_->start_shot_frameno = myself->room->GetFrameNo();
|
node_->start_shot_frameno = myself->room->GetFrameNo();
|
||||||
|
2
third_party/a8engine
vendored
2
third_party/a8engine
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 8b6410826da2c0c667abdacadae6d7c00f70300d
|
Subproject commit f32b842baf3c97def6871a831dd4509842d461ea
|
Loading…
x
Reference in New Issue
Block a user