This commit is contained in:
aozhiwei 2020-07-23 16:34:16 +08:00
parent c84825747d
commit 6242574bfd
5 changed files with 111 additions and 46 deletions

View File

@ -28,6 +28,7 @@
const int kReviveTimeAdd = 12;
const int kSkinNum = 4;
const int kREVIVE_BUFF_ID = 0;
Human::Human():MoveableEntity()
{
@ -980,32 +981,60 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
break;
}
}
++stats.dead_times;
stats.killer_id = killer_id;
stats.killer_name = killer_name;
stats.weapon_id = weapon_id;
dead = true;
downed = false;
ability.hp = 0.0f;
dead_frameno = room->GetFrameNo();
++dead_times;
if (HasBuffEffect(kBET_Camouflage)) {
RemoveBuffByEffectId(kBET_Camouflage);
}
ClearLordMode();
#ifdef DEBUG
room->CheckPartObjects();
#endif
int max_revive_times = MetaMgr::Instance()->GetSysParamAsInt("max_revive_times", 1);
if (weapon_id != VW_Spectate &&
dead_times <= max_revive_times &&
room->AliveCount() >= 5 &&
IsEntitySubType(EST_Player)) {
Revive();
} else {
if (room->GetRoomMode() == kZombieMode) {
dead = true;
downed = false;
real_dead = true;
OnDie();
dead_frameno = room->GetFrameNo();
DoGetDown();
if (HasBuffEffect(kBET_Camouflage)) {
RemoveBuffByEffectId(kBET_Camouflage);
}
ClearLordMode();
ClearBuffList();
room->frame_event.AddDead(this,
MetaMgr::Instance()->zbmode_revive_time * 1000);
SyncAroundPlayers(__FILE__, __LINE__, __func__);
room->xtimer.AddDeadLineTimerAndAttach
(MetaMgr::Instance()->zbmode_revive_time * SERVER_FRAME_RATE,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->Revive();
},
&xtimer_attacher.timer_list_
);
} else {
dead = true;
downed = false;
ability.hp = 0.0f;
dead_frameno = room->GetFrameNo();
++dead_times;
if (HasBuffEffect(kBET_Camouflage)) {
RemoveBuffByEffectId(kBET_Camouflage);
}
ClearLordMode();
#ifdef DEBUG
room->CheckPartObjects();
#endif
int max_revive_times = MetaMgr::Instance()->GetSysParamAsInt("max_revive_times", 1);
if (weapon_id != VW_Spectate &&
dead_times <= max_revive_times &&
room->AliveCount() >= 5 &&
IsEntitySubType(EST_Player)) {
Revive();
} else {
real_dead = true;
OnDie();
}
DoGetDown();
}
DoGetDown();
}
}
@ -2962,27 +2991,50 @@ void Human::RecalcBuffAttr()
void Human::Revive()
{
auto callback =
[] (const a8::XParams& param)
if (room->GetRoomMode() == kZombieMode) {
dead = false;
downed = false;
real_dead = false;
ability.hp = GetMaxHP();
ClearBuffList();
{
Human* hum = (Human*)param.sender.GetUserData();
hum->dead = true;
hum->real_dead = true;
hum->downed = false;
hum->OnDie();
};
int wait_revive_time = MetaMgr::Instance()->GetSysParamAsInt("revive_time", 25) + kReviveTimeAdd;
revive_timer = room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * wait_revive_time,
a8::XParams()
.SetSender(this),
callback,
&xtimer_attacher.timer_list_,
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->revive_timer = nullptr;
});
SyncAroundPlayers(__FILE__, __LINE__, __func__);
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(kREVIVE_BUFF_ID);
if (buff_meta) {
AddBuff(buff_meta, 1);
}
}
room->frame_event.AddRevive(this);
room->OnHumanRevive(this);
use_skill = false;
curr_skill_phase = 0;
skill_dir = a8::Vec2();
skill_param1 = 0.0f;
playing_skill = false;
SyncAroundPlayers(__FILE__, __LINE__, __func__);
} else {
auto callback =
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->dead = true;
hum->real_dead = true;
hum->downed = false;
hum->OnDie();
};
int wait_revive_time = MetaMgr::Instance()->GetSysParamAsInt("revive_time", 25) + kReviveTimeAdd;
revive_timer = room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * wait_revive_time,
a8::XParams()
.SetSender(this),
callback,
&xtimer_attacher.timer_list_,
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->revive_timer = nullptr;
});
SyncAroundPlayers(__FILE__, __LINE__, __func__);
}
}
void Human::ResetTankSkin()

View File

@ -48,6 +48,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set);
MetaData::AI* GetAI(int ai_level);
int zbmode_revive_time = 3;
int gas_inactive_time = 10;
int newbie_gas_inactive_time = 5;
int midbrid_gas_inactive_time = 15;

View File

@ -557,12 +557,21 @@ void Room::RemoveObjectLater(RoomEntity* entity)
void Room::OnHumanDie(Human* hum)
{
--alive_count_;
alive_count_chged_frameno_ = GetFrameNo();
--PerfMonitor::Instance()->alive_count;
RemoveFromAliveHumanHash(hum);
if (GetRoomMode() == kZombieMode) {
NotifyUiUpdate();
} else {
--alive_count_;
alive_count_chged_frameno_ = GetFrameNo();
--PerfMonitor::Instance()->alive_count;
RemoveFromAliveHumanHash(hum);
NotifyUiUpdate();
CheckShowHand();
}
}
void Room::OnHumanRevive(Human* hum)
{
NotifyUiUpdate();
CheckShowHand();
}
bool Room::OverBorder(const a8::Vec2 pos, float radius)

View File

@ -93,6 +93,7 @@ public:
a8::Vec2 pos, a8::Vec2 dir, float fly_distance, bool is_tank_skin = false);
void OnHumanDie(Human* hum);
void OnHumanRevive(Human* hum);
bool OverBorder(const a8::Vec2 pos, float radius);
Human* GetWatchWarTarget(Human* hum);
bool BattleStarted();

View File

@ -85,6 +85,8 @@ struct PlayerStats
int rank = 0;
int use_skill_times = 0;
int dead_times = 0;
};
struct CarObject