summaryrefslogtreecommitdiff
path: root/src/map/duel.c
diff options
context:
space:
mode:
authorEmistry Haoyan <Equinox1991@gmail.com>2016-10-27 23:45:43 +0800
committerHaru <haru@dotalux.com>2020-02-09 16:40:14 +0100
commit0f15d957cc0bb17415f85d26d2198ed248494e2f (patch)
treed862f2b600670db7b71adf3eb7d65e0bfa97fa4c /src/map/duel.c
parent3687a79c5ab173abf6263a003d9473d9c2938309 (diff)
downloadhercules-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/duel.c')
-rw-r--r--src/map/duel.c23
1 files changed, 4 insertions, 19 deletions
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;