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 MAX_SKILL_LV = 15;
const int CHECK_SHOT_HOLD_STATE_TIMER_EVENT = a8::TIMER_USER_EVENT + 1; 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 kReviveTimeAdd = 12;
const int kSkinNum = 4; const int kSkinNum = 4;

View File

@ -2137,15 +2137,31 @@ void Human::ProcUseItemAction()
case IS_SHEN_BAO: case IS_SHEN_BAO:
{ {
+stats.use_medicine_times; +stats.use_medicine_times;
if (!dead) { if (!shen_bao_timer.expired()) {
if (downed) { a8::Args args({item_meta->time()});
SetHP(mt::Param::s().downed_relive_recover_hp); room->xtimer.FireEvent(shen_bao_timer, SHEN_BAO_ADD_TIME_TIMER_EVENT, &args);
downed = false; } else {
if (!downed_timer.expired()) { int exec_time = 0;
room->xtimer.Delete(downed_timer); 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);
} }
AddHp(item_meta->heal()); },
&xtimer_attacher);
AddHp(heal);
} }
DecInventory(item_meta->_inventory_slot(), 1); DecInventory(item_meta->_inventory_slot(), 1);
MarkSyncActivePlayer(__FILE__, __LINE__, __func__); MarkSyncActivePlayer(__FILE__, __LINE__, __func__);