watchwar ok
This commit is contained in:
parent
97ee3ee957
commit
a379893fe5
@ -3277,22 +3277,7 @@ void Human::OnLand()
|
||||
MustBeAddBuff(this, kBeRecycleBuffId);
|
||||
}
|
||||
if (IsPlayer()) {
|
||||
refresh_view_timer_ = room->xtimer.AddRepeatTimerAndAttach
|
||||
(
|
||||
SERVER_FRAME_RATE * MetaMgr::Instance()->refresh_view_time,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->UpdateViewObjects();
|
||||
},
|
||||
&xtimer_attacher.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->refresh_view_timer_ = nullptr;
|
||||
});
|
||||
StartRefreshViewTimer();
|
||||
}
|
||||
if (CheckCollision()) {
|
||||
a8::Vec2 old_pos = GetPos();
|
||||
@ -3880,3 +3865,26 @@ Weapon* Human::TakeonWeapon(MetaData::Equip* equip_meta)
|
||||
}
|
||||
return weapon;
|
||||
}
|
||||
|
||||
void Human::StartRefreshViewTimer()
|
||||
{
|
||||
if (refresh_view_timer_) {
|
||||
return;
|
||||
}
|
||||
refresh_view_timer_ = room->xtimer.AddRepeatTimerAndAttach
|
||||
(
|
||||
SERVER_FRAME_RATE * MetaMgr::Instance()->refresh_view_time,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->UpdateViewObjects();
|
||||
},
|
||||
&xtimer_attacher.timer_list_,
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->refresh_view_timer_ = nullptr;
|
||||
});
|
||||
}
|
||||
|
@ -283,6 +283,7 @@ class Human : public Creature
|
||||
void UpdateViewObjects();
|
||||
void GMAddItem(int item_id, int item_num);
|
||||
void ProcUseItem(int item_id);
|
||||
void StartRefreshViewTimer();
|
||||
|
||||
protected:
|
||||
void _InternalUpdateMove(float speed);
|
||||
|
@ -128,22 +128,22 @@ void Incubator::RecycleAndroid(Human* hum)
|
||||
bool Incubator::CanSee(Human* hum, Human* exclude_hum)
|
||||
{
|
||||
Human* target = hum;
|
||||
bool can_set = true;
|
||||
bool can_see = true;
|
||||
room->TraverseAlivePlayers
|
||||
(
|
||||
a8::XParams(),
|
||||
[target, exclude_hum, &can_set] (Human* hum, a8::XParams& param) -> bool
|
||||
[target, exclude_hum, &can_see] (Human* hum, a8::XParams& param) -> bool
|
||||
{
|
||||
if (hum != exclude_hum) {
|
||||
if (target->GetPos().ManhattanDistance(hum->GetPos()) <
|
||||
MetaMgr::Instance()->incubator_canset_distance) {
|
||||
can_set = false;
|
||||
can_see = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return can_set;
|
||||
return can_see;
|
||||
}
|
||||
|
||||
void Incubator::AutoAllocAndroid()
|
||||
|
@ -1198,6 +1198,12 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
|
||||
GMAddItem(item_id, item_num);
|
||||
} else if (cmd == "infinite_bullet_mode") {
|
||||
room->SetInfiniteBulletMode();
|
||||
} else if (cmd == "watchwar") {
|
||||
Human* target = room->GetWatchWarTarget(hum);
|
||||
if (target) {
|
||||
FollowTarget(target);
|
||||
target->StartRefreshViewTimer();
|
||||
}
|
||||
} else if (cmd == "shuaguai" && cmds.size() >= 3) {
|
||||
int hero_id = a8::XValue(cmds[1]);
|
||||
int hero_num = a8::XValue(cmds[2]);
|
||||
@ -1405,6 +1411,7 @@ void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg)
|
||||
if (target) {
|
||||
hum->SendNotifyMsg(respmsg);
|
||||
hum->FollowTarget(target);
|
||||
target->StartRefreshViewTimer();
|
||||
} else {
|
||||
respmsg.set_error_code(1);
|
||||
hum->SendNotifyMsg(respmsg);
|
||||
|
@ -2847,7 +2847,7 @@ void Room::CheckAutoDie(Human* target,
|
||||
&target->xtimer_attacher.timer_list_);
|
||||
} else {
|
||||
std::vector<Human*> alive_humans;
|
||||
GetAliveHumans(alive_humans, 5, target);
|
||||
GetCanAutoDieHumans(alive_humans, 5, target);
|
||||
if (!alive_humans.empty()) {
|
||||
Human* killer = alive_humans[rand() % alive_humans.size()];
|
||||
a8::UnSetBitFlag(target->status, CS_Disable);
|
||||
@ -3023,6 +3023,34 @@ void Room::GetAliveHumans(std::vector<Human*>& alive_humans, size_t num, Human*
|
||||
}
|
||||
}
|
||||
|
||||
void Room::GetCanAutoDieHumans(std::vector<Human*>& alive_humans, size_t num, Human* exclude_hum)
|
||||
{
|
||||
alive_humans.reserve(num);
|
||||
{
|
||||
if (GetFrameNo() % 8 < 5) {
|
||||
for (auto itr = human_hash_.begin(); itr != human_hash_.end(); ++itr) {
|
||||
if (itr->second == exclude_hum) {
|
||||
continue;
|
||||
}
|
||||
CheckAliveHuman(itr->second, alive_humans);
|
||||
if (alive_humans.size() > num) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto itr = human_hash_.rbegin(); itr != human_hash_.rend(); ++itr) {
|
||||
if (itr->second == exclude_hum) {
|
||||
continue;
|
||||
}
|
||||
CheckAliveHuman(itr->second, alive_humans);
|
||||
if (alive_humans.size() > num) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans)
|
||||
{
|
||||
if (hum->IsAndroid() &&
|
||||
|
@ -270,6 +270,7 @@ private:
|
||||
void OnHumanGridChg(Human* target);
|
||||
void ShuaGridRound(Human* target);
|
||||
void GetAliveHumans(std::vector<Human*>& alive_humans, size_t num, Human* exclude_hum);
|
||||
void GetCanAutoDieHumans(std::vector<Human*>& alive_humans, size_t num, Human* exclude_hum);
|
||||
void CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans);
|
||||
a8::Vec2 GetDefaultBornPoint();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user