From 15e4ba4a14d912f70b0862bd1f0af9339dcbc6c0 Mon Sep 17 00:00:00 2001 From: wushin Date: Wed, 1 Apr 2015 01:27:04 -0500 Subject: Remove killer/killable Death Clears default pvp Add Player Togglable PvP Flag Add Timer to PvP Flag (Anti-Spam) Add getpvpflag builtin --- src/map/pc.cpp | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/map/pc.cpp') diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 7d04785..6a94f31 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -288,16 +288,10 @@ int pc_iskiller(dumb_ptr src, { nullpo_retz(src); - if (src->bl_type != BL::PC) + if (src->bl_type != BL::PC || target->bl_type != BL::PC) return 0; - if (src->special_state.killer) + if (src->state.pvpon && target->state.pvpon && !src->bl_m->flag.get(MapFlag::NOPVP)) return 1; - - if (target->bl_type != BL::PC) - return 0; - if (target->special_state.killable) - return 1; - return 0; } @@ -319,6 +313,33 @@ int distance(int x0, int y0, int x1, int y1) return dx > dy ? dx : dy; } +static +void pc_pvp_timer(TimerData *, tick_t, BlockId id) +{ + dumb_ptr sd = map_id2sd(id); + + assert (sd != nullptr); + assert (sd->bl_type == BL::PC); +} + +int pc_setpvptimer(dumb_ptr sd, interval_t val) +{ + nullpo_retz(sd); + + sd->pvp_timer = Timer(gettick() + val, + std::bind(pc_pvp_timer, ph::_1, ph::_2, + sd->bl_id)); + return 0; +} + +int pc_delpvptimer(dumb_ptr sd) +{ + nullpo_retz(sd); + + sd->pvp_timer.cancel(); + return 0; +} + static void pc_invincible_timer(TimerData *, tick_t, BlockId id) { @@ -378,7 +399,6 @@ int pc_setrestartvalue(dumb_ptr sd, int type) clif_updatestatus(sd, SP::SP); sd->heal_xp = 0; // [Fate] Set gainable xp for healing this player to 0 - return 0; } @@ -899,6 +919,7 @@ int pc_calcstatus(dumb_ptr sd, int first) int bl; int aspd_rate, refinedef = 0; int str, dstr, dex; + int b_pvpon = 0; nullpo_retz(sd); @@ -927,6 +948,8 @@ int pc_calcstatus(dumb_ptr sd, int first) b_mdef = sd->mdef; b_mdef2 = sd->mdef2; b_base_atk = sd->base_atk; + if (!pc_isdead(sd) && sd->state.pvpchannel == 1) + b_pvpchannel = sd->state.pvpchannel; sd->max_weight = max_weight_base_0 + sd->status.attrs[ATTR::STR] * 300; @@ -1399,6 +1422,8 @@ int pc_calcstatus(dumb_ptr sd, int first) clif_updatestatus(sd, SP::HP); if (b_sp != sd->status.sp) clif_updatestatus(sd, SP::SP); + if (b_pvpon != sd->state.pvpon) + sd->state.pvpon = b_pvpon; return 0; } -- cgit v1.2.3-70-g09d2