Group members share the same mob drops

This includes quest items.
This commit is contained in:
dongresource 2020-12-31 03:30:43 +01:00
parent dab204ddaf
commit 966bd3edd2
4 changed files with 27 additions and 19 deletions

View File

@ -514,7 +514,7 @@ void MissionManager::updateFusionMatter(CNSocket* sock, int fusion) {
PlayerManager::sendToViewable(sock, (void*)&bcast, P_FE2CL_PC_EVENT, sizeof(sP_FE2CL_PC_EVENT)); PlayerManager::sendToViewable(sock, (void*)&bcast, P_FE2CL_PC_EVENT, sizeof(sP_FE2CL_PC_EVENT));
} }
void MissionManager::mobKilled(CNSocket *sock, int mobid) { void MissionManager::mobKilled(CNSocket *sock, int mobid, int rolledQItem) {
Player *plr = PlayerManager::getPlayer(sock); Player *plr = PlayerManager::getPlayer(sock);
bool missionmob = false; bool missionmob = false;
@ -539,7 +539,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
} }
// drop quest item // drop quest item
if (task["m_iCSUItemNumNeeded"][j] != 0 && !isQuestItemFull(sock, task["m_iCSUItemID"][j], task["m_iCSUItemNumNeeded"][j]) ) { if (task["m_iCSUItemNumNeeded"][j] != 0 && !isQuestItemFull(sock, task["m_iCSUItemID"][j], task["m_iCSUItemNumNeeded"][j]) ) {
bool drop = rand() % 100 < task["m_iSTItemDropRate"][j]; bool drop = rolledQItem % 100 < task["m_iSTItemDropRate"][j];
if (drop) { if (drop) {
// XXX: are CSUItemID and CSTItemID the same? // XXX: are CSUItemID and CSTItemID the same?
dropQuestItem(sock, plr->tasks[i], 1, task["m_iCSUItemID"][j], mobid); dropQuestItem(sock, plr->tasks[i], 1, task["m_iCSUItemID"][j], mobid);

View File

@ -54,7 +54,7 @@ namespace MissionManager {
int giveMissionReward(CNSocket *sock, int task, int choice=0); int giveMissionReward(CNSocket *sock, int task, int choice=0);
void updateFusionMatter(CNSocket* sock, int fusion); void updateFusionMatter(CNSocket* sock, int fusion);
void mobKilled(CNSocket *sock, int mobid); void mobKilled(CNSocket *sock, int mobid, int rolledQItem);
bool endTask(CNSocket *sock, int32_t taskNum, int choice=0); bool endTask(CNSocket *sock, int32_t taskNum, int choice=0);
void saveMission(Player* player, int missionId); void saveMission(Player* player, int missionId);

View File

@ -152,7 +152,8 @@ void MobManager::npcAttackPc(Mob *mob, time_t currTime) {
} }
} }
void MobManager::giveReward(CNSocket *sock, Mob* mob) { void MobManager::giveReward(CNSocket *sock, Mob* mob, int rolledBoosts, int rolledPotions,
int rolledCrate, int rolledCrateType, int rolledEvent) {
Player *plr = PlayerManager::getPlayer(sock); Player *plr = PlayerManager::getPlayer(sock);
const size_t resplen = sizeof(sP_FE2CL_REP_REWARD_ITEM) + sizeof(sItemReward); const size_t resplen = sizeof(sP_FE2CL_REP_REWARD_ITEM) + sizeof(sItemReward);
@ -200,9 +201,9 @@ void MobManager::giveReward(CNSocket *sock, Mob* mob) {
// give boosts 1 in 3 times // give boosts 1 in 3 times
if (drop.boosts > 0) { if (drop.boosts > 0) {
if (rand() % 3 == 0) if (rolledPotions % 3 == 0)
plr->batteryN += drop.boosts; plr->batteryN += drop.boosts;
if (rand() % 3 == 0) if (rolledBoosts % 3 == 0)
plr->batteryW += drop.boosts; plr->batteryW += drop.boosts;
} }
// caps // caps
@ -230,7 +231,7 @@ void MobManager::giveReward(CNSocket *sock, Mob* mob) {
return; // this also prevents holiday crate drops, but oh well return; // this also prevents holiday crate drops, but oh well
} else { } else {
chance = &MobDropChances[drop.dropChanceType]; chance = &MobDropChances[drop.dropChanceType];
awardDrop = (rand() % 1000 < chance->dropChance); awardDrop = (rolledCrate % 1000 < chance->dropChance);
} }
// no drop // no drop
@ -240,7 +241,7 @@ void MobManager::giveReward(CNSocket *sock, Mob* mob) {
sock->sendPacket((void*)respbuf, P_FE2CL_REP_REWARD_ITEM, sizeof(sP_FE2CL_REP_REWARD_ITEM)); sock->sendPacket((void*)respbuf, P_FE2CL_REP_REWARD_ITEM, sizeof(sP_FE2CL_REP_REWARD_ITEM));
} else { } else {
// item reward // item reward
getReward(&item->sItem, &drop, chance); getReward(&item->sItem, &drop, chance, rolledCrateType);
item->iSlotNum = slot; item->iSlotNum = slot;
item->eIL = 1; // Inventory Location. 1 means player inventory. item->eIL = 1; // Inventory Location. 1 means player inventory.
@ -252,10 +253,10 @@ void MobManager::giveReward(CNSocket *sock, Mob* mob) {
// event crates // event crates
if (settings::EVENTMODE != 0) if (settings::EVENTMODE != 0)
giveEventReward(sock, plr); giveEventReward(sock, plr, rolledEvent);
} }
void MobManager::getReward(sItemBase *reward, MobDrop* drop, MobDropChance* chance) { void MobManager::getReward(sItemBase *reward, MobDrop* drop, MobDropChance* chance, int rolled) {
reward->iType = 9; reward->iType = 9;
reward->iOpt = 1; reward->iOpt = 1;
@ -264,7 +265,7 @@ void MobManager::getReward(sItemBase *reward, MobDrop* drop, MobDropChance* chan
total += ratio; total += ratio;
// randomizing a crate // randomizing a crate
int randomNum = rand() % total; int randomNum = rolled % total;
int i = 0; int i = 0;
int sum = 0; int sum = 0;
do { do {
@ -275,7 +276,7 @@ void MobManager::getReward(sItemBase *reward, MobDrop* drop, MobDropChance* chan
while (sum<=randomNum); while (sum<=randomNum);
} }
void MobManager::giveEventReward(CNSocket* sock, Player* player) { void MobManager::giveEventReward(CNSocket* sock, Player* player, int rolled) {
// random drop chance // random drop chance
if (rand() % 100 > settings::EVENTCRATECHANCE) if (rand() % 100 > settings::EVENTCRATECHANCE)
return; return;
@ -385,9 +386,16 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
if (sock != nullptr) { if (sock != nullptr) {
Player* plr = PlayerManager::getPlayer(sock); Player* plr = PlayerManager::getPlayer(sock);
int rolledBoosts = rand();
int rolledPotions = rand();
int rolledCrate = rand();
int rolledCrateType = rand();
int rolledEvent = rand();
int rolledQItem = rand();
if (plr->groupCnt == 1 && plr->iIDGroup == plr->iID) { if (plr->groupCnt == 1 && plr->iIDGroup == plr->iID) {
giveReward(sock, mob); giveReward(sock, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType); MissionManager::mobKilled(sock, mob->appearanceData.iNPCType, rolledQItem);
} else { } else {
Player* otherPlayer = PlayerManager::getPlayerFromID(plr->iIDGroup); Player* otherPlayer = PlayerManager::getPlayerFromID(plr->iIDGroup);
@ -406,8 +414,8 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
if (dist > 5000) if (dist > 5000)
continue; continue;
giveReward(sockTo, mob); giveReward(sockTo, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
MissionManager::mobKilled(sockTo, mob->appearanceData.iNPCType); MissionManager::mobKilled(sockTo, mob->appearanceData.iNPCType, rolledQItem);
} }
} }
} }

View File

@ -167,9 +167,9 @@ namespace MobManager {
void npcAttackPc(Mob *mob, time_t currTime); void npcAttackPc(Mob *mob, time_t currTime);
int hitMob(CNSocket *sock, Mob *mob, int damage); int hitMob(CNSocket *sock, Mob *mob, int damage);
void killMob(CNSocket *sock, Mob *mob); void killMob(CNSocket *sock, Mob *mob);
void giveReward(CNSocket *sock, Mob *mob); void giveReward(CNSocket *sock, Mob *mob, int rolledBoosts, int rolledPotions, int rolledCrate, int rolledCrateType, int rolledEvent);
void getReward(sItemBase *reward, MobDrop *drop, MobDropChance *chance); void getReward(sItemBase *reward, MobDrop *drop, MobDropChance *chance, int rolled);
void giveEventReward(CNSocket* sock, Player* player); void giveEventReward(CNSocket* sock, Player* player, int rolled);
std::pair<int,int> lerp(int, int, int, int, int); std::pair<int,int> lerp(int, int, int, int, int);
std::pair<int,int> getDamage(int, int, bool, bool, int, int, int); std::pair<int,int> getDamage(int, int, bool, bool, int, int, int);