[Rules] Add adjustment for zone forage. (#2330)

* [Rules] Add adjustment for zone forage.

- Added rule to allow the adjustment of zone foraging %

* Cleanup if formating
This commit is contained in:
Michael
2022-07-30 14:39:12 -04:00
committed by GitHub
parent 25705878d8
commit 0f9427098d
2 changed files with 17 additions and 19 deletions
+16 -19
View File
@@ -419,7 +419,6 @@ void Client::GoFish()
}
void Client::ForageItem(bool guarantee) {
int skill_level = GetSkill(EQ::skills::SkillForage);
//be wary of the string ids in switch below when changing this.
@@ -439,12 +438,12 @@ void Client::ForageItem(bool guarantee) {
uint32 foragedfood = 0;
uint32 stringid = FORAGE_NOEAT;
if (zone->random.Roll(25)) {
if (zone->random.Roll(RuleI(Zone, ForageChance))) {
foragedfood = content_db.GetZoneForage(m_pp.zone_id, skill_level);
}
//not an else in case theres no DB food
if(foragedfood == 0) {
if (foragedfood == 0) {
uint8 index = 0;
index = zone->random.Int(0, MAX_COMMON_FOOD_IDS-1);
foragedfood = common_food_ids[index];
@@ -452,48 +451,49 @@ void Client::ForageItem(bool guarantee) {
const EQ::ItemData* food_item = database.GetItem(foragedfood);
if(!food_item) {
if (!food_item) {
LogError("nullptr returned from database.GetItem in ClientForageItem");
return;
}
if(foragedfood == 13106)
if (foragedfood == 13106) {
stringid = FORAGE_GRUBS;
else
} else {
switch(food_item->ItemType) {
case EQ::item::ItemTypeFood:
stringid = FORAGE_FOOD;
break;
case EQ::item::ItemTypeDrink:
if(strstr(food_item->Name, "ater"))
if (strstr(food_item->Name, "ater")) {
stringid = FORAGE_WATER;
else
} else {
stringid = FORAGE_DRINK;
}
break;
default:
break;
}
}
MessageString(Chat::Skills, stringid);
EQ::ItemInstance* inst = database.CreateItem(food_item, 1);
if(inst != nullptr) {
if (inst != nullptr) {
// check to make sure it isn't a foraged lore item
if(CheckLoreConflict(inst->GetItem()))
{
if (CheckLoreConflict(inst->GetItem())) {
MessageString(Chat::White, DUP_LORE);
safe_delete(inst);
}
else {
} else {
PushItemOnCursor(*inst);
SendItemPacket(EQ::invslot::slotCursor, inst, ItemPacketLimbo);
if(RuleB(TaskSystem, EnableTaskSystem))
if(RuleB(TaskSystem, EnableTaskSystem)) {
UpdateTasksForItem(TaskActivityType::Forage, foragedfood);
}
safe_delete(inst);
inst = m_inv.GetItem(EQ::invslot::slotCursor);
}
if(inst) {
if (inst) {
std::vector<std::any> args;
args.push_back(inst);
parse->EventPlayer(EVENT_FORAGE_SUCCESS, this, "", inst->GetID(), &args);
@@ -501,17 +501,14 @@ void Client::ForageItem(bool guarantee) {
}
int ChanceSecondForage = aabonuses.ForageAdditionalItems + itembonuses.ForageAdditionalItems + spellbonuses.ForageAdditionalItems;
if(!guarantee && zone->random.Roll(ChanceSecondForage)) {
if (!guarantee && zone->random.Roll(ChanceSecondForage)) {
MessageString(Chat::Skills, FORAGE_MASTERY);
ForageItem(true);
}
} else {
MessageString(Chat::Skills, FORAGE_FAILED);
parse->EventPlayer(EVENT_FORAGE_FAILURE, this, "", 0);
}
CheckIncreaseSkill(EQ::skills::SkillForage, nullptr, 5);
}