1
This commit is contained in:
parent
7894f91e25
commit
3c77e04f00
@ -284,6 +284,7 @@ protected:
|
|||||||
int camouflage_aiming_addition_ = 0;
|
int camouflage_aiming_addition_ = 0;
|
||||||
long long last_follow_move_frameno_ = 0;
|
long long last_follow_move_frameno_ = 0;
|
||||||
int follow_target_last_chg_move_dir_times_ = -1;
|
int follow_target_last_chg_move_dir_times_ = -1;
|
||||||
|
xtimer_list* follow_target_timer_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CreatureWeakPtr weak_ptr_;
|
CreatureWeakPtr weak_ptr_;
|
||||||
|
@ -3662,3 +3662,67 @@ void Human::DropWeapon(int weapon_idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::DoFollow(int target_id)
|
||||||
|
{
|
||||||
|
if (target_id == 0){
|
||||||
|
if (follow_target.Get()) {
|
||||||
|
follow_target.Detach();
|
||||||
|
room->frame_event.AddPropChg(GetWeakPtrRef(), kPropFollowTarget, 0, 0, true);
|
||||||
|
if (follow_target_timer_) {
|
||||||
|
room->xtimer.DeleteTimer(follow_target_timer_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (GetTeam()) {
|
||||||
|
Human* member = GetTeam()->GetMemberByUniId(target_id);
|
||||||
|
if (member && member->CanFollow(this)) {
|
||||||
|
if (follow_target.Get()) {
|
||||||
|
follow_target.Detach();
|
||||||
|
if (follow_target_timer_) {
|
||||||
|
room->xtimer.DeleteTimer(follow_target_timer_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
follow_target_last_chg_move_dir_times_ = -1;
|
||||||
|
follow_target.Attach(member);
|
||||||
|
room->frame_event.AddPropChg(GetWeakPtrRef(), kPropFollowTarget, 0, target_id, true);
|
||||||
|
follow_target_timer_ = room->xtimer.AddRepeatTimerAndAttach
|
||||||
|
(
|
||||||
|
400 / FRAME_RATE_MS,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Player* hum = (Player*)param.sender.GetUserData();
|
||||||
|
if (!hum->follow_target.Get()) {
|
||||||
|
hum->room->xtimer.DeleteTimer(hum->room->xtimer.GetRunningTimer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (hum->room->GetGasData().gas_mode != GasInactive &&
|
||||||
|
!(hum->follow_target.Get()->HasBuffEffect(kBET_Fly) ||
|
||||||
|
hum->follow_target.Get()->HasBuffEffect(kBET_Jump))
|
||||||
|
){
|
||||||
|
hum->follow_target.Detach();
|
||||||
|
hum->room->xtimer.DeleteTimer(hum->room->xtimer.GetRunningTimer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hum->follow_target.Get()->HasBuffEffect(kBET_Jump)) {
|
||||||
|
if (hum->HasBuffEffect(kBET_Jump)) {
|
||||||
|
hum->FollowToTarget();
|
||||||
|
} else {
|
||||||
|
hum->DoJump();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&xtimer_attacher.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Player* hum = (Player*)param.sender.GetUserData();
|
||||||
|
hum->follow_target_timer_ = nullptr;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IncFollowTimes();
|
||||||
|
}
|
||||||
|
@ -268,6 +268,7 @@ class Human : public Creature
|
|||||||
void GMAddItem(int item_id, int item_num);
|
void GMAddItem(int item_id, int item_num);
|
||||||
void ProcUseItem(int item_id);
|
void ProcUseItem(int item_id);
|
||||||
void StartRefreshViewTimer();
|
void StartRefreshViewTimer();
|
||||||
|
void DoFollow(int target_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _InternalUpdateMove(float speed);
|
void _InternalUpdateMove(float speed);
|
||||||
|
@ -1244,66 +1244,7 @@ void Player::UpdateAiming()
|
|||||||
|
|
||||||
void Player::UpdateFollow()
|
void Player::UpdateFollow()
|
||||||
{
|
{
|
||||||
if (follow == 0){
|
DoFollow(follow);
|
||||||
if (follow_target.Get()) {
|
|
||||||
follow_target.Detach();
|
|
||||||
room->frame_event.AddPropChg(GetWeakPtrRef(), kPropFollowTarget, 0, 0, true);
|
|
||||||
if (follow_target_timer_) {
|
|
||||||
room->xtimer.DeleteTimer(follow_target_timer_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (GetTeam()) {
|
|
||||||
Human* member = GetTeam()->GetMemberByUniId(follow);
|
|
||||||
if (member && member->CanFollow(this)) {
|
|
||||||
if (follow_target.Get()) {
|
|
||||||
follow_target.Detach();
|
|
||||||
if (follow_target_timer_) {
|
|
||||||
room->xtimer.DeleteTimer(follow_target_timer_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
follow_target_last_chg_move_dir_times_ = -1;
|
|
||||||
follow_target.Attach(member);
|
|
||||||
room->frame_event.AddPropChg(GetWeakPtrRef(), kPropFollowTarget, 0, follow, true);
|
|
||||||
follow_target_timer_ = room->xtimer.AddRepeatTimerAndAttach
|
|
||||||
(
|
|
||||||
400 / FRAME_RATE_MS,
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(this),
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
Player* hum = (Player*)param.sender.GetUserData();
|
|
||||||
if (!hum->follow_target.Get()) {
|
|
||||||
hum->room->xtimer.DeleteTimer(hum->room->xtimer.GetRunningTimer());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (hum->room->GetGasData().gas_mode != GasInactive &&
|
|
||||||
!(hum->follow_target.Get()->HasBuffEffect(kBET_Fly) ||
|
|
||||||
hum->follow_target.Get()->HasBuffEffect(kBET_Jump))
|
|
||||||
){
|
|
||||||
hum->follow_target.Detach();
|
|
||||||
hum->room->xtimer.DeleteTimer(hum->room->xtimer.GetRunningTimer());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hum->follow_target.Get()->HasBuffEffect(kBET_Jump)) {
|
|
||||||
if (hum->HasBuffEffect(kBET_Jump)) {
|
|
||||||
hum->FollowToTarget();
|
|
||||||
} else {
|
|
||||||
hum->DoJump();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&xtimer_attacher.timer_list_,
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
Player* hum = (Player*)param.sender.GetUserData();
|
|
||||||
hum->follow_target_timer_ = nullptr;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IncFollowTimes();
|
|
||||||
follow = -1;
|
follow = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,6 @@ private:
|
|||||||
std::set<int> receved_box_hash_;
|
std::set<int> receved_box_hash_;
|
||||||
long long last_cmmove_frameno_ = 0;
|
long long last_cmmove_frameno_ = 0;
|
||||||
xtimer_list* watch_war_req_timer_ = nullptr;
|
xtimer_list* watch_war_req_timer_ = nullptr;
|
||||||
xtimer_list* follow_target_timer_ = nullptr;
|
|
||||||
|
|
||||||
friend class EntityFactory;
|
friend class EntityFactory;
|
||||||
};
|
};
|
||||||
|
@ -1360,7 +1360,9 @@ void Room::MatchTeam(Human* hum)
|
|||||||
if (pair.second != hum) {
|
if (pair.second != hum) {
|
||||||
if (!hum->team_uuid.empty() && pair.second->team_uuid == hum->team_uuid) {
|
if (!hum->team_uuid.empty() && pair.second->team_uuid == hum->team_uuid) {
|
||||||
if (!pair.second->GetTeam()) {
|
if (!pair.second->GetTeam()) {
|
||||||
NewTeam()->AddMember(pair.second);
|
Team* new_team = NewTeam();
|
||||||
|
new_team->SetInitTeamMemberNum(hum->init_team_member_num);
|
||||||
|
new_team->AddMember(pair.second);
|
||||||
}
|
}
|
||||||
if (!pair.second->GetTeam()->IsFull()) {
|
if (!pair.second->GetTeam()->IsFull()) {
|
||||||
pair.second->GetTeam()->AddMember(hum);
|
pair.second->GetTeam()->AddMember(hum);
|
||||||
@ -1377,6 +1379,11 @@ void Room::MatchTeam(Human* hum)
|
|||||||
|
|
||||||
void Room::CombineTeam()
|
void Room::CombineTeam()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
if (MetaMgr::Instance()->prebattle_combine_team) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
std::map<int, size_t> need_combine_teams;
|
std::map<int, size_t> need_combine_teams;
|
||||||
std::map<int, size_t> need_combine_teams_copy;
|
std::map<int, size_t> need_combine_teams_copy;
|
||||||
|
|
||||||
|
@ -45,11 +45,14 @@ bool Team::HasAliveMember()
|
|||||||
|
|
||||||
void Team::AddMember(Human* member)
|
void Team::AddMember(Human* member)
|
||||||
{
|
{
|
||||||
|
if (!first_member_) {
|
||||||
|
first_member_ = member;
|
||||||
|
}
|
||||||
member->team_id = team_id_;
|
member->team_id = team_id_;
|
||||||
member->SetTeam(this);
|
member->SetTeam(this);
|
||||||
members_.insert(member);
|
members_.insert(member);
|
||||||
if (member->GetFollowTimes() <= 0) {
|
if (member->GetFollowTimes() <= 0 && member != first_member_ && !member->follow_target.Get()) {
|
||||||
|
member->DoFollow(first_member_->GetUniId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ class Team
|
|||||||
public:
|
public:
|
||||||
Room* room = nullptr;
|
Room* room = nullptr;
|
||||||
|
|
||||||
|
void SetInitTeamMemberNum(int init_num) { init_team_member_num_ = init_num; };
|
||||||
int GetTeamId() { return team_id_; }
|
int GetTeamId() { return team_id_; }
|
||||||
void SetTeamId(int team_id) { team_id_ = team_id; }
|
void SetTeamId(int team_id) { team_id_ = team_id; }
|
||||||
void TraverseMembers(std::function<bool (Human*)> func);
|
void TraverseMembers(std::function<bool (Human*)> func);
|
||||||
@ -26,4 +27,5 @@ class Team
|
|||||||
int team_id_ = 0;
|
int team_id_ = 0;
|
||||||
int init_team_member_num_ = 0;
|
int init_team_member_num_ = 0;
|
||||||
std::set<Human*> members_;
|
std::set<Human*> members_;
|
||||||
|
Human* first_member_ = nullptr;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user