diff options
author | Emistry Haoyan <Equinox1991@gmail.com> | 2016-10-27 23:45:43 +0800 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2020-02-09 16:40:14 +0100 |
commit | 0f15d957cc0bb17415f85d26d2198ed248494e2f (patch) | |
tree | d862f2b600670db7b71adf3eb7d65e0bfa97fa4c /src/map | |
parent | 3687a79c5ab173abf6263a003d9473d9c2938309 (diff) | |
download | hercules-0f15d957cc0bb17415f85d26d2198ed248494e2f.tar.gz hercules-0f15d957cc0bb17415f85d26d2198ed248494e2f.tar.bz2 hercules-0f15d957cc0bb17415f85d26d2198ed248494e2f.tar.xz hercules-0f15d957cc0bb17415f85d26d2198ed248494e2f.zip |
Update Duel System Cooldown
- Able to set cooldown in "seconds" format.
- New `duel_time_interval` value will be applied to any existing cooldown
if new value is reloaded in-game using `@reloadbattleconf`.
- Display the cooldown tick before can create new duel.
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 14 | ||||
-rw-r--r-- | src/map/duel.c | 23 | ||||
-rw-r--r-- | src/map/duel.h | 2 |
3 files changed, 13 insertions, 26 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 3cd26079d..5d95e2c14 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8048,10 +8048,11 @@ ACMD(duel) return false; } - if (!duel->checktime(sd)) { + int64 diff = duel->difftime(sd); + if (diff > 0) { char output[CHAT_SIZE_MAX]; - // "Duel: You can take part in duel only one time per %d minutes." - sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval); + // "Duel: You can take part in duel again after %d secconds." + sprintf(output, msg_fd(fd,356), (int)diff); clif->message(fd, output); return false; } @@ -8101,10 +8102,11 @@ ACMD(leave) ACMD(accept) { - if (!duel->checktime(sd)) { + int64 diff = duel->difftime(sd); + if (diff > 0) { char output[CHAT_SIZE_MAX]; - // "Duel: You can take part in duel only one time per %d minutes." - sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval); + // "Duel: You can take part in duel again after %d seconds." + sprintf(output, msg_fd(fd,356), (int)diff); clif->message(fd, output); return false; } diff --git a/src/map/duel.c b/src/map/duel.c index dca040f83..c66fd6fc2 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -41,27 +41,12 @@ struct duel_interface *duel; *------------------------------------------*/ static void duel_savetime(struct map_session_data *sd) { - time_t clock; - struct tm *t; - - time(&clock); - t = localtime(&clock); - - pc_setglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME"), t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min); + pc_setglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME"), (int)time(NULL)); } -static int duel_checktime(struct map_session_data *sd) +static int64 duel_difftime(struct map_session_data *sd) { - int diff; - time_t clock; - struct tm *t; - - time(&clock); - t = localtime(&clock); - - diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min - pc_readglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME") ); - - return !(diff >= 0 && diff < battle_config.duel_time_interval); + return (pc_readglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME")) + battle_config.duel_time_interval - (int)time(NULL)); } static int duel_showinfo_sub(struct map_session_data *sd, va_list va) @@ -233,7 +218,7 @@ void duel_defaults(void) duel->reject = duel_reject; duel->leave = duel_leave; duel->showinfo = duel_showinfo; - duel->checktime = duel_checktime; + duel->difftime = duel_difftime; duel->init = do_init_duel; duel->final = do_final_duel; diff --git a/src/map/duel.h b/src/map/duel.h index 4e8985b96..1620ca891 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -52,7 +52,7 @@ struct duel_interface { void (*reject) (const unsigned int did, struct map_session_data* sd); void (*leave) (const unsigned int did, struct map_session_data* sd); void (*showinfo) (const unsigned int did, struct map_session_data* sd); - int (*checktime) (struct map_session_data* sd); + int64 (*difftime) (struct map_session_data* sd); void (*init) (bool minimal); void (*final) (void); |