This commit is contained in:
aozhiwei 2021-10-22 16:38:18 +08:00
parent ee3226984a
commit 0daaa3ec3f
2 changed files with 24 additions and 2 deletions

View File

@ -787,7 +787,6 @@ void Buff::ProcRemoveDive()
void Buff::ProcInWater()
{
if (owner->IsHuman()) {
owner->AsHuman()->SetOxygen(MetaMgr::Instance()->dive_oxygen_total);
owner->AsHuman()->room->frame_event.AddPropChg
(owner->AsHuman()->GetWeakPtrRef(),
kPropDive,
@ -828,6 +827,28 @@ void Buff::ProcInWater()
void Buff::ProcRemoveInWater()
{
if (owner->IsHuman()) {
owner->AsHuman()->SetOxygen(0);
if (owner->IsPlayer()) {
owner->room->xtimer.AddRepeatTimerAndAttach
(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(owner),
[] (const a8::XParams& param)
{
Creature* c = (Creature*)param.sender.GetUserData();
if (!c->IsHuman() || c->HasBuffEffect(kBET_InWater) || c->dead) {
c->room->xtimer.DeleteTimer(c->room->xtimer.GetRunningTimer());
return;
}
Human* hum = c->AsHuman();
if (hum->GetOxygen() >= MetaMgr::Instance()->dive_oxygen_total) {
c->room->xtimer.DeleteTimer(c->room->xtimer.GetRunningTimer());
return;
}
hum->AddOxygen(MetaMgr::Instance()->inwater_oxygen_recover);
},
&owner->xtimer_attacher.timer_list_
);
}
}
}

View File

@ -77,6 +77,7 @@ void Human::Initialize()
}
SetMaxHP(GetHP());
SetCurrWeapon(&weapons[0]);
SetOxygen(MetaMgr::Instance()->dive_oxygen_total);
}
float Human::GetSpeed()