Cedit Player Kill and Player Thief (#160) -- WhiskyTest

* cedit configuration for player kill and steal

* tidy up pk_allowed
This commit is contained in:
MBourne
2026-02-03 23:55:59 +00:00
committed by GitHub
parent 4e1680db1a
commit 0d5d2bc435
14 changed files with 152 additions and 58 deletions
+34 -12
View File
@@ -110,10 +110,13 @@ void update_pos(struct char_data *victim)
void check_killer(struct char_data *ch, struct char_data *vict)
{
if (PLR_FLAGGED(vict, PLR_KILLER) || PLR_FLAGGED(vict, PLR_THIEF))
return;
if (PLR_FLAGGED(ch, PLR_KILLER) || IS_NPC(ch) || IS_NPC(vict) || ch == vict)
if (PLR_FLAGGED(vict, PLR_KILLER) || PLR_FLAGGED(vict, PLR_THIEF)) {
return;
}
if (PLR_FLAGGED(ch, PLR_KILLER) || IS_NPC(ch) || IS_NPC(vict) || ch == vict){
return;
}
SET_BIT_AR(PLR_FLAGS(ch), PLR_KILLER);
send_to_char(ch, "If you want to be a PLAYER KILLER, so be it...\r\n");
@@ -122,6 +125,22 @@ void check_killer(struct char_data *ch, struct char_data *vict)
GET_NAME(ch), GET_NAME(vict), world[IN_ROOM(vict)].name);
}
bool pk_allowed(struct char_data *ch, struct char_data *victim)
{
/* NPCs are never restricted */
if (IS_NPC(ch) || IS_NPC(victim))
return true;
if (CONFIG_PK_SETTING == CONFIG_PK_OFF)
return false;
if (CONFIG_PK_SETTING == CONFIG_PK_LIMITED)
check_killer(ch, victim);
return true;
}
/* start one char fighting another (yes, it is horrible, I know... ) */
void set_fighting(struct char_data *ch, struct char_data *vict)
{
@@ -133,6 +152,12 @@ void set_fighting(struct char_data *ch, struct char_data *vict)
return;
}
if (!pk_allowed(ch, vict)) {
send_to_char(ch, "Player killing is not permitted.\r\n");
return;
}
ch->next_fighting = combat_list;
combat_list = ch;
@@ -142,8 +167,6 @@ void set_fighting(struct char_data *ch, struct char_data *vict)
FIGHTING(ch) = vict;
GET_POS(ch) = POS_FIGHTING;
if (!CONFIG_PK_ALLOWED)
check_killer(ch, vict);
}
/* remove a char from the list of fighting chars */
@@ -603,6 +626,12 @@ int damage(struct char_data *ch, struct char_data *victim, int dam, int attackty
return (-1); /* -je, 7/7/92 */
}
/* Check for PK if this is not a PK MUD */
if (!pk_allowed(ch, victim)) {
send_to_char(ch, "Player killing is not permitted.\r\n");
return (0);
}
/* peaceful rooms */
if (ch->nr != real_mobile(DG_CASTER_PROXY) &&
ch != victim && ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {
@@ -650,13 +679,6 @@ int damage(struct char_data *ch, struct char_data *victim, int dam, int attackty
if (AFF_FLAGGED(victim, AFF_SANCTUARY) && dam >= 2)
dam /= 2;
/* Check for PK if this is not a PK MUD */
if (!CONFIG_PK_ALLOWED) {
check_killer(ch, victim);
if (PLR_FLAGGED(ch, PLR_KILLER) && (ch != victim))
dam = 0;
}
/* Set the maximum damage per round and subtract the hit points */
dam = MAX(MIN(dam, 100), 0);
GET_HIT(victim) -= dam;