The simplest way to do that is via a status effect. You give the status when the player uses @pk, and when the status runs out, it removes the pk mode.
int atcommand_pkmode( const int fd, struct map_session_data *sd, const char *command, const char *message ) {
nullpo_retr(-1, sd);
if (!sd->state.pk_mode) {
sd->state.pk_mode = 1;
sc_start(&sd->bl, &sd->bl, SC_PK_DISABLE, 100, 0, 60 * 60 * 10000);
clif_displaymessage(sd->fd, "You are now no longer in PK mode.");
} else {
sd->state.pk_mode = 0;
status_change_end(&sd->bl, SC_PK_DISABLE);
clif_displaymessage(sd->fd, "Returned to normal state.");
}
return 0;
}
And define the SC_PK_DISABLE status:
diff --git a/db/re/status.yml b/db/re/status.yml
index 96693fdce..40693394c 100644
--- a/db/re/status.yml
+++ b/db/re/status.yml
@@ -8166,3 +8166,9 @@ Body:
NoClearbuff: true
End:
Sub_Weaponproperty: true
+ - Status: Pk_Disable
+ #Icon: EFST_PK_DISABLE
+ Flags:
+ NoDispell: true
+ NoBanishingBuster: true
+ NoClearance: true
diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp
index 25ce19a67..ddbd1c466 100644
--- a/src/map/script_constants.hpp
+++ b/src/map/script_constants.hpp
@@ -1844,6 +1844,7 @@
export_constant(SC_M_LIFEPOTION);
export_constant(SC_S_MANAPOTION);
export_constant(SC_SUB_WEAPONPROPERTY);
+ export_constant(SC_PK_DISABLE);
#ifdef RENEWAL
export_constant(SC_EXTREMITYFIST2);
diff --git a/src/map/status.cpp b/src/map/status.cpp
index 42005bdae..4b6f462fb 100644
--- a/src/map/status.cpp
+++ b/src/map/status.cpp
@@ -13351,6 +13351,11 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
pc_delabyssball( *sd, sd->abyssball );
}
break;
+ case SC_PK_DISABLE:
+ if (sd) {
+ sd->state.pk_mode = 0;
+ }
+ break;
}
// Reset the options as needed
diff --git a/src/map/status.hpp b/src/map/status.hpp
index f103cd018..f2b79e058 100644
--- a/src/map/status.hpp
+++ b/src/map/status.hpp
@@ -1230,7 +1230,7 @@ enum sc_type : int16 {
SC_S_MANAPOTION,
SC_SUB_WEAPONPROPERTY,
-
+ SC_PK_DISABLE,
#ifdef RENEWAL
SC_EXTREMITYFIST2, //! NOTE: This SC should be right before SC_MAX, so it doesn't disturb if RENEWAL is disabled
#endif
(Also... shouldn't this message "You are now no longer in PK mode." be "You are now in PK mode." instead?)