From 0b7768837bed2aa521de5b9b76b2348943d7db20 Mon Sep 17 00:00:00 2001 From: Jedzkie Date: Sun, 31 May 2020 10:53:09 +0800 Subject: Added configuration on allowing actions on player when dead. --- conf/map/battle/player.conf | 7 +++++++ src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/clif.c | 25 +++++++++++++------------ src/map/pc.h | 6 ++++++ src/map/script.c | 5 +++++ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/conf/map/battle/player.conf b/conf/map/battle/player.conf index b691f7343..4658b1296 100644 --- a/conf/map/battle/player.conf +++ b/conf/map/battle/player.conf @@ -226,3 +226,10 @@ shadow_refine_atk: true // Keep player facing direction after warping? // Default: false (on official servers players always faces north) player_warp_keep_direction: true + +// Can dead players do actions like trading, open a chat room, etc.? +// 0x0 - Don't allow trading and open chat rooms. +// 0x1 - Allow trading when dead. +// 0x2 - Allow open chat room when dead. +// default: 0x3 (Official) +allowed_actions_when_dead: 0x3 diff --git a/src/map/battle.c b/src/map/battle.c index c8cd71b94..f5976a434 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7448,6 +7448,7 @@ static const struct battle_data { { "hit_max_limit", &battle_config.hit_max, SHRT_MAX, 1, INT_MAX, }, { "autoloot_adjust", &battle_config.autoloot_adjust, 0, 0, 1, }, { "hom_bonus_exp_from_master", &battle_config.hom_bonus_exp_from_master, 10, 0, 100, }, + { "allowed_actions_when_dead", &battle_config.allowed_actions_when_dead, 0, 0, 3, }, }; static bool battle_set_value_sub(int index, int value) diff --git a/src/map/battle.h b/src/map/battle.h index bb907d5b9..24594f4e6 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -607,6 +607,7 @@ struct Battle_Config { int hit_max; int autoloot_adjust; + int allowed_actions_when_dead; }; /* criteria for battle_config.idletime_critera */ diff --git a/src/map/clif.c b/src/map/clif.c index 7be5c6978..d52082e62 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12283,7 +12283,7 @@ static void clif_parse_CreateChatRoom(int fd, struct map_session_data *sd) __att /// 1 = public static void clif_parse_CreateChatRoom(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_CHAT) == 0) || pc_isvending(sd)) return; int len = (int)RFIFOW(fd, 2) - 15; @@ -12331,7 +12331,7 @@ static void clif_parse_ChatAddMember(int fd, struct map_session_data *sd) __attr /// 00d9 .L .8B static void clif_parse_ChatAddMember(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_CHAT) == 0) || pc_isvending(sd)) return; int chatid = RFIFOL(fd,2); @@ -12348,7 +12348,7 @@ static void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data *sd) /// 1 = public static void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_CHAT) == 0) || pc_isvending(sd)) return; int len = (int)RFIFOW(fd, 2) - 15; @@ -12383,7 +12383,7 @@ static void clif_parse_ChangeChatOwner(int fd, struct map_session_data *sd) __at /// 1 = normal static void clif_parse_ChangeChatOwner(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_CHAT) == 0) || pc_isvending(sd)) return; chat->change_owner(sd, RFIFOP(fd,6)); // non null terminated @@ -12394,7 +12394,7 @@ static void clif_parse_KickFromChat(int fd, struct map_session_data *sd) __attri /// 00e2 .24B static void clif_parse_KickFromChat(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_CHAT) == 0) || pc_isvending(sd)) return; chat->kick(sd, RFIFOP(fd,2)); // non null terminated @@ -12405,7 +12405,7 @@ static void clif_parse_ChatLeave(int fd, struct map_session_data *sd) __attribut /// 00e3 static void clif_parse_ChatLeave(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_CHAT) == 0) || pc_isvending(sd)) return; chat->leave(sd, false); @@ -12432,7 +12432,7 @@ static void clif_parse_TradeRequest(int fd, struct map_session_data *sd) __attri /// 00e4 .L static void clif_parse_TradeRequest(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_TRADE) == 0) || pc_isvending(sd)) return; struct map_session_data *t_sd = map->id2sd(RFIFOL(fd, 2)); @@ -12462,7 +12462,7 @@ static void clif_parse_TradeAck(int fd, struct map_session_data *sd) __attribute /// 4 = rejected static void clif_parse_TradeAck(int fd, struct map_session_data *sd) { - if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_TRADE) == 0) || pc_isvending(sd)) return; trade->ack(sd,RFIFOB(fd,2)); @@ -12473,7 +12473,7 @@ static void clif_parse_TradeAddItem(int fd, struct map_session_data *sd) __attri /// 00e8 .W .L static void clif_parse_TradeAddItem(int fd, struct map_session_data *sd) { - if (!sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + if (sd->state.trading == 0 || (pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_TRADE) == 0) || pc_isvending(sd)) return; short index = RFIFOW(fd,2); @@ -12490,8 +12490,9 @@ static void clif_parse_TradeOk(int fd, struct map_session_data *sd) __attribute_ /// 00eb static void clif_parse_TradeOk(int fd, struct map_session_data *sd) { - if (pc_isdead(sd) || pc_isvending(sd)) + if ((pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_TRADE) == 0) || pc_isvending(sd)) return; + trade->ok(sd); } @@ -12500,7 +12501,7 @@ static void clif_parse_TradeCancel(int fd, struct map_session_data *sd) __attrib /// 00ed static void clif_parse_TradeCancel(int fd, struct map_session_data *sd) { - if (pc_isdead(sd) || pc_isvending(sd)) + if ((pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_TRADE) == 0) || pc_isvending(sd)) return; trade->cancel(sd); @@ -12511,7 +12512,7 @@ static void clif_parse_TradeCommit(int fd, struct map_session_data *sd) __attrib /// 00ef static void clif_parse_TradeCommit(int fd, struct map_session_data *sd) { - if (pc_isdead(sd) || pc_isvending(sd)) + if ((pc_isdead(sd) && (battle_config.allowed_actions_when_dead & PCALLOWACTION_TRADE) == 0) || pc_isvending(sd)) return; trade->commit(sd); diff --git a/src/map/pc.h b/src/map/pc.h index e560df549..acd8c73df 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -868,6 +868,12 @@ struct class_exp_tables { struct class_exp_group *class_exp_table[CLASS_COUNT][2]; }; +enum player_actions_when_dead_flags { + PCALLOWACTION_NONE = 0x0, // Don't allow trading and open chat rooms. + PCALLOWACTION_TRADE = 0x1, // Allow trading when dead. + PCALLOWACTION_CHAT = 0x2, // Allow open chat room when dead. +}; + /*===================================== * Interface : pc.h * Generated by HerculesInterfaceMaker diff --git a/src/map/script.c b/src/map/script.c index 45c954dc0..1ae20c42a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -27871,6 +27871,11 @@ static void script_hardcoded_constants(void) script->set_constant("P_AIRSHIP_INVALID_END_MAP", P_AIRSHIP_INVALID_END_MAP, false, false); script->set_constant("P_AIRSHIP_ITEM_NOT_ENOUGH", P_AIRSHIP_ITEM_NOT_ENOUGH, false, false); script->set_constant("P_AIRSHIP_ITEM_INVALID", P_AIRSHIP_ITEM_INVALID, false, false); + + script->constdb_comment("player allowed actions when dead"); + script->set_constant("PCALLOWACTION_NONE", PCALLOWACTION_NONE, false, false); + script->set_constant("PCALLOWACTION_TRADE", PCALLOWACTION_TRADE, false, false); + script->set_constant("PCALLOWACTION_CHAT", PCALLOWACTION_CHAT, false, false); script->constdb_comment("questinfo types"); script->set_constant("QINFO_JOB", QINFO_JOB, false, false); -- cgit v1.2.3-60-g2f50