mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 03:40:05 +00:00
Group members share the same mob drops
This includes quest items.
This commit is contained in:
parent
dab204ddaf
commit
966bd3edd2
@ -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));
|
||||
}
|
||||
|
||||
void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
||||
void MissionManager::mobKilled(CNSocket *sock, int mobid, int rolledQItem) {
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
bool missionmob = false;
|
||||
@ -539,7 +539,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
||||
}
|
||||
// drop quest item
|
||||
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) {
|
||||
// XXX: are CSUItemID and CSTItemID the same?
|
||||
dropQuestItem(sock, plr->tasks[i], 1, task["m_iCSUItemID"][j], mobid);
|
||||
|
@ -54,7 +54,7 @@ namespace MissionManager {
|
||||
int giveMissionReward(CNSocket *sock, int task, int choice=0);
|
||||
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);
|
||||
void saveMission(Player* player, int missionId);
|
||||
|
@ -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);
|
||||
|
||||
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
|
||||
if (drop.boosts > 0) {
|
||||
if (rand() % 3 == 0)
|
||||
if (rolledPotions % 3 == 0)
|
||||
plr->batteryN += drop.boosts;
|
||||
if (rand() % 3 == 0)
|
||||
if (rolledBoosts % 3 == 0)
|
||||
plr->batteryW += drop.boosts;
|
||||
}
|
||||
// caps
|
||||
@ -230,7 +231,7 @@ void MobManager::giveReward(CNSocket *sock, Mob* mob) {
|
||||
return; // this also prevents holiday crate drops, but oh well
|
||||
} else {
|
||||
chance = &MobDropChances[drop.dropChanceType];
|
||||
awardDrop = (rand() % 1000 < chance->dropChance);
|
||||
awardDrop = (rolledCrate % 1000 < chance->dropChance);
|
||||
}
|
||||
|
||||
// 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));
|
||||
} else {
|
||||
// item reward
|
||||
getReward(&item->sItem, &drop, chance);
|
||||
getReward(&item->sItem, &drop, chance, rolledCrateType);
|
||||
item->iSlotNum = slot;
|
||||
item->eIL = 1; // Inventory Location. 1 means player inventory.
|
||||
|
||||
@ -252,10 +253,10 @@ void MobManager::giveReward(CNSocket *sock, Mob* mob) {
|
||||
|
||||
// event crates
|
||||
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->iOpt = 1;
|
||||
|
||||
@ -264,7 +265,7 @@ void MobManager::getReward(sItemBase *reward, MobDrop* drop, MobDropChance* chan
|
||||
total += ratio;
|
||||
|
||||
// randomizing a crate
|
||||
int randomNum = rand() % total;
|
||||
int randomNum = rolled % total;
|
||||
int i = 0;
|
||||
int sum = 0;
|
||||
do {
|
||||
@ -275,7 +276,7 @@ void MobManager::getReward(sItemBase *reward, MobDrop* drop, MobDropChance* chan
|
||||
while (sum<=randomNum);
|
||||
}
|
||||
|
||||
void MobManager::giveEventReward(CNSocket* sock, Player* player) {
|
||||
void MobManager::giveEventReward(CNSocket* sock, Player* player, int rolled) {
|
||||
// random drop chance
|
||||
if (rand() % 100 > settings::EVENTCRATECHANCE)
|
||||
return;
|
||||
@ -385,9 +386,16 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
|
||||
if (sock != nullptr) {
|
||||
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) {
|
||||
giveReward(sock, mob);
|
||||
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType);
|
||||
giveReward(sock, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
|
||||
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType, rolledQItem);
|
||||
} else {
|
||||
Player* otherPlayer = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
@ -406,8 +414,8 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
|
||||
if (dist > 5000)
|
||||
continue;
|
||||
|
||||
giveReward(sockTo, mob);
|
||||
MissionManager::mobKilled(sockTo, mob->appearanceData.iNPCType);
|
||||
giveReward(sockTo, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
|
||||
MissionManager::mobKilled(sockTo, mob->appearanceData.iNPCType, rolledQItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,9 +167,9 @@ namespace MobManager {
|
||||
void npcAttackPc(Mob *mob, time_t currTime);
|
||||
int hitMob(CNSocket *sock, Mob *mob, int damage);
|
||||
void killMob(CNSocket *sock, Mob *mob);
|
||||
void giveReward(CNSocket *sock, Mob *mob);
|
||||
void getReward(sItemBase *reward, MobDrop *drop, MobDropChance *chance);
|
||||
void giveEventReward(CNSocket* sock, Player* player);
|
||||
void giveReward(CNSocket *sock, Mob *mob, int rolledBoosts, int rolledPotions, int rolledCrate, int rolledCrateType, int rolledEvent);
|
||||
void getReward(sItemBase *reward, MobDrop *drop, MobDropChance *chance, int rolled);
|
||||
void giveEventReward(CNSocket* sock, Player* player, int rolled);
|
||||
|
||||
std::pair<int,int> lerp(int, int, int, int, int);
|
||||
std::pair<int,int> getDamage(int, int, bool, bool, int, int, int);
|
||||
|
Loading…
Reference in New Issue
Block a user