mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 23:01:30 +00:00
[Bug Fix] Fix fishing chances (#4203)
Fix regression from #4008 where the item count wasn't being incremented Move the zone table chance to a rule General cleanup of some initializers and variable types
This commit is contained in:
parent
523ba30d81
commit
6a8bd3c5d6
@ -355,6 +355,7 @@ RULE_INT(Zone, GlobalLootMultiplier, 1, "Sets Global Loot drop multiplier for da
|
|||||||
RULE_BOOL(Zone, KillProcessOnDynamicShutdown, true, "When process has booted a zone and has hit its zone shut down timer, it will hard kill the process to free memory back to the OS")
|
RULE_BOOL(Zone, KillProcessOnDynamicShutdown, true, "When process has booted a zone and has hit its zone shut down timer, it will hard kill the process to free memory back to the OS")
|
||||||
RULE_INT(Zone, SpawnEventMin, 3, "When strict is set in spawn_events, specifies the max EQ minutes into the trigger hour a spawn_event will fire. Going below 3 may cause the spawn_event to not fire.")
|
RULE_INT(Zone, SpawnEventMin, 3, "When strict is set in spawn_events, specifies the max EQ minutes into the trigger hour a spawn_event will fire. Going below 3 may cause the spawn_event to not fire.")
|
||||||
RULE_INT(Zone, ForageChance, 25, "Chance of foraging from zone table vs global table")
|
RULE_INT(Zone, ForageChance, 25, "Chance of foraging from zone table vs global table")
|
||||||
|
RULE_INT(Zone, FishingChance, 399, "Chance of fishing from zone table vs global table")
|
||||||
RULE_BOOL(Zone, AllowCrossZoneSpellsOnBots, false, "Set to true to allow cross zone spells (cast/remove) to affect bots")
|
RULE_BOOL(Zone, AllowCrossZoneSpellsOnBots, false, "Set to true to allow cross zone spells (cast/remove) to affect bots")
|
||||||
RULE_BOOL(Zone, AllowCrossZoneSpellsOnMercs, false, "Set to true to allow cross zone spells (cast/remove) to affect mercenaries")
|
RULE_BOOL(Zone, AllowCrossZoneSpellsOnMercs, false, "Set to true to allow cross zone spells (cast/remove) to affect mercenaries")
|
||||||
RULE_BOOL(Zone, AllowCrossZoneSpellsOnPets, false, "Set to true to allow cross zone spells (cast/remove) to affect pets")
|
RULE_BOOL(Zone, AllowCrossZoneSpellsOnPets, false, "Set to true to allow cross zone spells (cast/remove) to affect pets")
|
||||||
|
|||||||
@ -44,17 +44,14 @@ extern WorldServer worldserver;
|
|||||||
|
|
||||||
struct NPCType;
|
struct NPCType;
|
||||||
|
|
||||||
//max number of items which can be in the foraging table
|
//max number of items which can be in the foraging
|
||||||
//for a given zone.
|
// and fishing tables for a given zone.
|
||||||
#define FORAGE_ITEM_LIMIT 50
|
constexpr uint8 FORAGE_ITEM_LIMIT = 50;
|
||||||
|
constexpr uint8 FISHING_ITEM_LIMIT = 50;
|
||||||
|
|
||||||
uint32 ZoneDatabase::LoadForage(uint32 zone_id, uint8 skill_level)
|
uint32 ZoneDatabase::LoadForage(uint32 zone_id, uint8 skill_level)
|
||||||
{
|
{
|
||||||
uint32 forage_items[FORAGE_ITEM_LIMIT];
|
uint32 forage_items[FORAGE_ITEM_LIMIT] = {};
|
||||||
|
|
||||||
for (uint16 slot_id = 0; slot_id < FORAGE_ITEM_LIMIT; slot_id++) {
|
|
||||||
forage_items[slot_id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& l = ForageRepository::GetWhere(
|
const auto& l = ForageRepository::GetWhere(
|
||||||
*this,
|
*this,
|
||||||
@ -77,7 +74,7 @@ uint32 ZoneDatabase::LoadForage(uint32 zone_id, uint8 skill_level)
|
|||||||
l.size() != 1 ? "s" : ""
|
l.size() != 1 ? "s" : ""
|
||||||
);
|
);
|
||||||
|
|
||||||
int forage_chances[FORAGE_ITEM_LIMIT];
|
int forage_chances[FORAGE_ITEM_LIMIT] = {};
|
||||||
|
|
||||||
int current_chance = 0;
|
int current_chance = 0;
|
||||||
uint32 item_id = 0;
|
uint32 item_id = 0;
|
||||||
@ -118,13 +115,8 @@ uint32 ZoneDatabase::LoadForage(uint32 zone_id, uint8 skill_level)
|
|||||||
|
|
||||||
uint32 ZoneDatabase::LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_id, uint8 &npc_chance)
|
uint32 ZoneDatabase::LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_id, uint8 &npc_chance)
|
||||||
{
|
{
|
||||||
uint32 fishing_items[50];
|
uint32 fishing_items[FISHING_ITEM_LIMIT] = {};
|
||||||
int fishing_chances[50];
|
int fishing_chances[FISHING_ITEM_LIMIT] = {};
|
||||||
|
|
||||||
for (uint16 slot_id = 0; slot_id < 50; slot_id++) {
|
|
||||||
fishing_items[slot_id] = 0;
|
|
||||||
fishing_chances[slot_id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& l = FishingRepository::GetWhere(
|
const auto& l = FishingRepository::GetWhere(
|
||||||
*this,
|
*this,
|
||||||
@ -146,15 +138,15 @@ uint32 ZoneDatabase::LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_
|
|||||||
l.size() != 1 ? "s" : ""
|
l.size() != 1 ? "s" : ""
|
||||||
);
|
);
|
||||||
|
|
||||||
uint32 npc_ids[50];
|
uint32 npc_ids[FISHING_ITEM_LIMIT] = {};
|
||||||
uint32 npc_chances[50];
|
uint32 npc_chances[FISHING_ITEM_LIMIT] = {};
|
||||||
|
|
||||||
int current_chance = 0;
|
int current_chance = 0;
|
||||||
uint32 item_id = 0;
|
uint32 item_id = 0;
|
||||||
uint8 count = 0;
|
uint8 count = 0;
|
||||||
|
|
||||||
for (const auto &e: l) {
|
for (const auto &e: l) {
|
||||||
if (count >= 50) {
|
if (count >= FISHING_ITEM_LIMIT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +156,8 @@ uint32 ZoneDatabase::LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_
|
|||||||
npc_chances[count] = e.npc_chance;
|
npc_chances[count] = e.npc_chance;
|
||||||
|
|
||||||
current_chance = fishing_chances[count];
|
current_chance = fishing_chances[count];
|
||||||
|
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
npc_id = 0;
|
npc_id = 0;
|
||||||
@ -175,7 +169,7 @@ uint32 ZoneDatabase::LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_
|
|||||||
|
|
||||||
const int roll = zone->random.Int(1, current_chance);
|
const int roll = zone->random.Int(1, current_chance);
|
||||||
|
|
||||||
for (uint16 i = 0; i < count; i++) {
|
for (uint8 i = 0; i < count; i++) {
|
||||||
if (roll > fishing_chances[i]) {
|
if (roll > fishing_chances[i]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -269,8 +263,9 @@ void Client::GoFish(bool guarantee, bool use_bait)
|
|||||||
fishing_timer.Disable();
|
fishing_timer.Disable();
|
||||||
|
|
||||||
//we're doing this a second time (1st in Client::Handle_OP_Fishing) to make sure that, between when we started fishing & now, we're still able to fish (in case we move, change equip, etc)
|
//we're doing this a second time (1st in Client::Handle_OP_Fishing) to make sure that, between when we started fishing & now, we're still able to fish (in case we move, change equip, etc)
|
||||||
if (!CanFish()) //if we can't fish here, we don't need to bother with the rest
|
if (!CanFish()) { //if we can't fish here, we don't need to bother with the rest
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//multiple entries yeilds higher probability of dropping...
|
//multiple entries yeilds higher probability of dropping...
|
||||||
uint32 common_fish_ids[MAX_COMMON_FISH_IDS] = {
|
uint32 common_fish_ids[MAX_COMMON_FISH_IDS] = {
|
||||||
@ -283,18 +278,18 @@ void Client::GoFish(bool guarantee, bool use_bait)
|
|||||||
7007, // Rusty Dagger
|
7007, // Rusty Dagger
|
||||||
7007, // Rusty Dagger
|
7007, // Rusty Dagger
|
||||||
7007 // Rusty Dagger
|
7007 // Rusty Dagger
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//success formula is not researched at all
|
//success formula is not researched at all
|
||||||
|
|
||||||
int fishing_skill = GetSkill(EQ::skills::SkillFishing); //will take into account skill bonuses on pole & bait
|
uint16 fishing_skill = GetSkill(EQ::skills::SkillFishing); //will take into account skill bonuses on pole & bait
|
||||||
|
|
||||||
//make sure we still have a fishing pole on:
|
//make sure we still have a fishing pole on:
|
||||||
int32 bslot = m_inv.HasItemByUse(EQ::item::ItemTypeFishingBait, 1, invWhereWorn | invWherePersonal);
|
int16 bslot = m_inv.HasItemByUse(EQ::item::ItemTypeFishingBait, 1, invWhereWorn | invWherePersonal);
|
||||||
const EQ::ItemInstance* Bait = nullptr;
|
const EQ::ItemInstance* Bait = nullptr;
|
||||||
if (bslot != INVALID_INDEX)
|
if (bslot != INVALID_INDEX) {
|
||||||
Bait = m_inv.GetItem(bslot);
|
Bait = m_inv.GetItem(bslot);
|
||||||
|
}
|
||||||
|
|
||||||
//if the bait isnt equipped, need to add its skill bonus
|
//if the bait isnt equipped, need to add its skill bonus
|
||||||
if (bslot >= EQ::invslot::GENERAL_BEGIN && Bait != nullptr && Bait->GetItem()->SkillModType == EQ::skills::SkillFishing) {
|
if (bslot >= EQ::invslot::GENERAL_BEGIN && Bait != nullptr && Bait->GetItem()->SkillModType == EQ::skills::SkillFishing) {
|
||||||
@ -309,8 +304,8 @@ void Client::GoFish(bool guarantee, bool use_bait)
|
|||||||
if (guarantee || zone->random.Int(0,175) < fishing_skill) {
|
if (guarantee || zone->random.Int(0,175) < fishing_skill) {
|
||||||
uint32 food_id = 0;
|
uint32 food_id = 0;
|
||||||
|
|
||||||
//25% chance to fish an item.
|
//chance to fish a zone item.
|
||||||
if (zone->random.Int(0, 399) <= fishing_skill ) {
|
if (zone->random.Int(0, RuleI(Zone, FishingChance)) <= fishing_skill ) {
|
||||||
uint32 npc_id = 0;
|
uint32 npc_id = 0;
|
||||||
uint8 npc_chance = 0;
|
uint8 npc_chance = 0;
|
||||||
food_id = content_db.LoadFishing(m_pp.zone_id, fishing_skill, npc_id, npc_chance);
|
food_id = content_db.LoadFishing(m_pp.zone_id, fishing_skill, npc_id, npc_chance);
|
||||||
@ -449,8 +444,8 @@ void Client::ForageItem(bool guarantee) {
|
|||||||
13419, // Vegetables
|
13419, // Vegetables
|
||||||
13048, // Rabbit Meat
|
13048, // Rabbit Meat
|
||||||
13047, // Roots
|
13047, // Roots
|
||||||
13044, // Pod Of Water
|
13044, // Pod of Water
|
||||||
14905, // mushroom
|
14905, // Mushroom
|
||||||
13106 // Fishing Grubs
|
13106 // Fishing Grubs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user