diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 438de9109..572597710 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -14868,14 +14868,15 @@ void Client::Handle_OP_Split(const EQApplicationPacket *app) Group *group = nullptr; Raid *raid = nullptr; - if (IsRaidGrouped()) + if (IsRaidGrouped()) { raid = GetRaid(); - else if (IsGrouped()) + } else if (IsGrouped()) { group = GetGroup(); + } // is there an actual error message for this? if (raid == nullptr && group == nullptr) { - Message(Chat::Red, "You can not split money if you're not in a group."); + MessageString(Chat::Red, SPLIT_NO_GROUP); return; } @@ -14883,14 +14884,15 @@ void Client::Handle_OP_Split(const EQApplicationPacket *app) 10 * static_cast(split->silver) + 100 * static_cast(split->gold) + 1000 * static_cast(split->platinum))) { - Message(Chat::Red, "You do not have enough money to do that split."); + MessageString(Chat::Red, SPLIT_FAIL); return; } - if (raid) + if (raid) { raid->SplitMoney(raid->GetGroup(this), split->copper, split->silver, split->gold, split->platinum); - else if (group) - group->SplitMoney(split->copper, split->silver, split->gold, split->platinum, this); + } else if (group) { + group->SplitMoney(split->copper, split->silver, split->gold, split->platinum, this, true); + } return; diff --git a/zone/groups.cpp b/zone/groups.cpp index 193441393..1e8ee4739 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -115,7 +115,7 @@ Group::~Group() } //Split money used in OP_Split (/split and /autosplit). -void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter) +void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter, bool share) { // Return early if no money to split. if (!copper && !silver && !gold && !platinum) { @@ -152,6 +152,8 @@ void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinu return; } + uint8 random_member = zone->random.Int(0, member_count - 1); + // Calculate split and remainder for each coin type uint32 copper_split = copper / member_count; uint32 copper_remainder = copper % member_count; @@ -167,21 +169,38 @@ void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinu if (m && m->IsClient()) { Client *member_client = m->CastToClient(); - uint32 receive_copper = copper_split; - uint32 receive_silver = silver_split; + uint32 receive_copper = copper_split; + uint32 receive_silver = silver_split; uint32 receive_gold = gold_split; uint32 receive_platinum = platinum_split; - // splitter gets the remainders of coin - if (member_client == splitter) { - receive_copper += copper_remainder; - receive_silver += silver_remainder; - receive_gold += gold_remainder; + // if /split is used then splitter gets the remainder + split. + // if /autosplit is used then random players in the group will get the remainder + split. + if(share ? member_client == splitter : member_client == members[random_member]) { + receive_copper += copper_remainder; + receive_silver += silver_remainder; + receive_gold += gold_remainder; receive_platinum += platinum_remainder; } - // Add the coins to the player's purse. - member_client->AddMoneyToPP(receive_copper, receive_silver, receive_gold, receive_platinum, true); + // the group member other than the character doing the /split only gets this message "(splitter) shares the money with the group" + if (share && member_client != splitter) { + member_client->MessageString( + YOU_RECEIVE_AS_SPLIT, + SHARE_MONEY, + splitter->GetCleanName() + ); + } + + // Check if there are any coins to add to the player's purse. + if (receive_copper || receive_silver || receive_gold || receive_platinum) { + member_client->AddMoneyToPP(receive_copper, receive_silver, receive_gold, receive_platinum, true); + member_client->MessageString( + Chat::MoneySplit, + YOU_RECEIVE_AS_SPLIT, + Strings::Money(receive_platinum, receive_gold, receive_silver, receive_copper).c_str() + ); + } // If logging of player money transactions is enabled, record the transaction. if (player_event_logs.IsEventEnabled(PlayerEvent::SPLIT_MONEY)) { @@ -194,13 +213,6 @@ void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinu }; RecordPlayerEventLogWithClient(member_client, PlayerEvent::SPLIT_MONEY, e); } - - // Notify the player of their received coins. - member_client->MessageString( - Chat::MoneySplit, - YOU_RECEIVE_AS_SPLIT, - Strings::Money(receive_platinum, receive_gold, receive_silver, receive_copper).c_str() - ); } } } diff --git a/zone/groups.h b/zone/groups.h index 51426f960..28954ee75 100644 --- a/zone/groups.h +++ b/zone/groups.h @@ -80,7 +80,7 @@ public: void GroupMessage(Mob* sender,uint8 language,uint8 lang_skill,const char* message); void GroupMessageString(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0); uint32 GetTotalGroupDamage(Mob* other); - void SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter = nullptr); + void SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter = nullptr, bool share = false); inline void SetLeader(Mob* c){ leader = c; }; inline Mob* GetLeader() { return leader; }; std::string GetLeaderName(); diff --git a/zone/string_ids.h b/zone/string_ids.h index 9e432d0e7..96b6deb0e 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -179,6 +179,7 @@ #define CORPSE_DECAY_TIME_MINUTE 495 //This corpse will decay in %1 minute(s) %2 seconds. #define DISC_LEVEL_ERROR 503 //You must be a level %1 ... to use this discipline. #define DISCIPLINE_CANUSEIN 504 //You can use a new discipline in %1 minutes %2 seconds. +#define SHARE_MONEY 511 //%1 shares money with the group. #define PVP_ON 552 //You are now player kill and follow the ways of Discord. #define GENERIC_STRINGID_SAY 554 //%1 says '%T2' #define CANNOT_WAKE 555 //%1 tells you, 'I am unable to wake %2, master.' @@ -530,6 +531,8 @@ #define GROUP_INVITEE_NOT_FOUND 12268 //You must target a player or use /invite to invite someone to your group. #define GROUP_INVITEE_SELF 12270 //12270 You cannot invite yourself. #define ALREADY_IN_PARTY 12272 //That person is already in your party. +#define TALKING_TO_SELF 12323 //Talking to yourself again? +#define SPLIT_NO_GROUP 12328 //You are not in a group! Keep it all. #define NO_LONGER_HIDDEN 12337 //You are no longer hidden. #define STOP_SNEAKING 12338 //You stop sneaking #define NOT_IN_CONTROL 12368 //You do not have control of yourself right now. @@ -580,6 +583,7 @@ #define HOT_HEAL_OTHER 12997 //You have healed %1 for %2 hit points with your %3. #define HOT_HEALED_OTHER 12998 //%1 healed you for %2 hit points by %3. #define DISC_LEVEL_USE_ERROR 13004 //You are not sufficient level to use this discipline. +#define SPLIT_FAIL 13112 //There is not enough to split, keep it. #define TOGGLE_ON 13172 //Asking server to turn ON your incoming tells. #define TOGGLE_OFF 13173 //Asking server to turn OFF all incoming tells for you. #define DUEL_INPROGRESS 13251 //You have already accepted a duel with someone else cowardly dog.