This commit is contained in:
aozhiwei 2023-02-13 18:07:15 +08:00
parent e776c8a890
commit a2a919a400
2 changed files with 26 additions and 9 deletions

View File

@ -531,6 +531,7 @@ const int ANDROID_AI_ID_START = 10001;
const int MAX_SKILL_LV = 15;
const int CHECK_SHOT_HOLD_STATE_TIMER_EVENT = a8::TIMER_USER_EVENT + 1;
const int SHEN_BAO_ADD_TIME_TIMER_EVENT = a8::TIMER_USER_EVENT + 2;
const int kReviveTimeAdd = 12;
const int kSkinNum = 4;

View File

@ -2137,15 +2137,31 @@ void Human::ProcUseItemAction()
case IS_SHEN_BAO:
{
+stats.use_medicine_times;
if (!dead) {
if (downed) {
SetHP(mt::Param::s().downed_relive_recover_hp);
downed = false;
if (!downed_timer.expired()) {
room->xtimer.Delete(downed_timer);
}
}
AddHp(item_meta->heal());
if (!shen_bao_timer.expired()) {
a8::Args args({item_meta->time()});
room->xtimer.FireEvent(shen_bao_timer, SHEN_BAO_ADD_TIME_TIMER_EVENT, &args);
} else {
int exec_time = 0;
int total_time = item_meta->time();
int heal = item_meta->heal();
shen_bao_timer = room->xtimer.SetIntervalWpEx
(
SERVER_FRAME_RATE,
[this, exec_time, total_time, heal] (int event, const a8::Args* args) mutable
{
if (a8::TIMER_EXEC_EVENT == event) {
exec_time += 1;
if (exec_time >= total_time || dead) {
room->xtimer.DeleteCurrentTimer();
} else {
AddHp(heal);
}
} else if (SHEN_BAO_ADD_TIME_TIMER_EVENT == event) {
total_time += args->Get<int>(0);
}
},
&xtimer_attacher);
AddHp(heal);
}
DecInventory(item_meta->_inventory_slot(), 1);
MarkSyncActivePlayer(__FILE__, __LINE__, __func__);