summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.cpp14
-rw-r--r--src/map/magic-stmt.cpp2
-rw-r--r--src/map/map.hpp2
-rw-r--r--src/map/pc.cpp10
-rw-r--r--src/map/script-fun.cpp12
5 files changed, 22 insertions, 18 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 2a5791e..7c165ef 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -4033,17 +4033,19 @@ static
ATCE atcommand_pvp(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- if (sd->pvp_timer)
+ int chan = sd->state.pvpchannel;
+ if (sd->pvp_timer || (chan > 1))
return ATCE::OKAY;
- sd->state.pvpon = !sd->state.pvpon;
- pc_setpvptimer(sd, battle_config.player_pvp_time);
-
- if (sd->state.pvpon)
+ if (chan < 1) {
+ sd->state.pvpchannel = 1;
clif_displaymessage(s, "##3PvP : ##BOn"_s);
- else
+ } else {
+ sd->state.pvpchannel = 0;
clif_displaymessage(s, "##3PvP : ##BOff"_s);
+ }
+ pc_setpvptimer(sd, battle_config.player_pvp_time);
return ATCE::OKAY;
}
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 544b290..fdeac3a 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -774,7 +774,7 @@ int op_injure(dumb_ptr<env_t> env, Slice<val_t> args)
if (target->bl_type == BL::PC
&& !target->bl_m->flag.get(MapFlag::PVP)
&& (caster->bl_type != BL::PC)
- && (!target->is_player()->state.pvpon && !caster->is_player()->state.pvpon))
+ && ((caster->is_player()->state.pvpchannel > 1) && (target->is_player()->state.pvpchannel != caster->is_player()->state.pvpchannel)))
return 0; /* Cannot damage other players outside of pvp */
if (target != caster)
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 9e15851..f57dcee 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -142,7 +142,7 @@ struct map_session_data : block_list, SessionData
unsigned shroud_disappears_on_pickup:1;
unsigned shroud_disappears_on_talk:1;
unsigned seen_motd:1;
- unsigned pvpon:1;
+ unsigned pvpchannel;
} state;
struct
{
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 6a94f31..8b0391b 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -290,7 +290,9 @@ int pc_iskiller(dumb_ptr<map_session_data> src,
if (src->bl_type != BL::PC || target->bl_type != BL::PC)
return 0;
- if (src->state.pvpon && target->state.pvpon && !src->bl_m->flag.get(MapFlag::NOPVP))
+ if ((src->state.pvpchannel == 1) && (target->state.pvpchannel == 1) && !src->bl_m->flag.get(MapFlag::NOPVP))
+ return 1;
+ if ((src->state.pvpchannel > 1) && (target->state.pvpchannel == src->state.pvpchannel)) // this one does not respect NOPVP
return 1;
return 0;
}
@@ -919,7 +921,7 @@ int pc_calcstatus(dumb_ptr<map_session_data> sd, int first)
int bl;
int aspd_rate, refinedef = 0;
int str, dstr, dex;
- int b_pvpon = 0;
+ int b_pvpchannel = 0;
nullpo_retz(sd);
@@ -1422,8 +1424,8 @@ int pc_calcstatus(dumb_ptr<map_session_data> 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;
+ if (b_pvpchannel != sd->state.pvpchannel)
+ sd->state.pvpchannel = b_pvpchannel;
return 0;
}
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index f08cf60..1d587fd 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2176,15 +2176,15 @@ void builtin_pvpoff(ScriptState *st)
}
static
-void builtin_pvp(ScriptState *st)
+void builtin_setpvpchannel(ScriptState *st)
{
dumb_ptr<map_session_data> sd = script_rid2sd(st);
int flag;
flag = conv_num(st, &AARG(0));
- if (flag > 1)
- flag = 1;
+ if (flag < 1)
+ flag = 0;
- sd->state.pvpon = flag;
+ sd->state.pvpchannel = flag;
}
static
@@ -2196,7 +2196,7 @@ void builtin_getpvpflag(ScriptState *st)
switch (num){
case 0:
- flag = sd->state.pvpon;
+ flag = sd->state.pvpchannel;
break;
case 1:
flag = bool(sd->status.option & Opt0::HIDE);
@@ -3109,7 +3109,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(getmapflag, "Mi"_s, 'i'),
BUILTIN(pvpon, "M"_s, '\0'),
BUILTIN(pvpoff, "M"_s, '\0'),
- BUILTIN(pvp, "i"_s, '\0'),
+ BUILTIN(setpvpchannel, "i"_s, '\0'),
BUILTIN(getpvpflag, "i"_s, 'i'),
BUILTIN(emotion, "i"_s, '\0'),
BUILTIN(mapwarp, "MMxy"_s, '\0'),