cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
179 stars 47 forks source link

🐛 [Classic & TBC] Fishing in low skill zones #3760

Open al3xc1985 opened 3 weeks ago

al3xc1985 commented 3 weeks ago

Bug Details

First I have to give credits to @insunaa for the provided patch. He is a wotlk guy (Thx God for him) :)

On classic and tbc, and not woltk starting with 3.1, u have a message when try to fish into a zone. If your skill is not inoff, u get this message from the picture below.

Each zone has a specific skill min/max for fishing and getting skill. Currently we don't have that implemented. I talked with @insunaa about it and he made for me a fast patch, but I can't test it, and I let it here for disscussions

This is a list with skills by zone https://wowwiki-archive.fandom.com/wiki/Fishing_skill_requirements_by_zone image

diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp
index 07c850412..d103f692a 100644
--- a/src/game/Spells/Spell.cpp
+++ b/src/game/Spells/Spell.cpp
@@ -2151,12 +2151,21 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, bool targ
         }
         case TARGET_LOCATION_CASTER_FISHING_SPOT:
         {
+            SpellCastResult result = SPELL_CAST_OK;
+            uint32 zone, subzone;
+            m_caster->GetZoneAndAreaId(zone, subzone);
+            int32 zone_skill = sObjectMgr.GetFishingBaseSkillLevel(subzone);
+            if (!zone_skill)
+                zone_skill = sObjectMgr.GetFishingBaseSkillLevel(zone);
+            int32 skill = static_cast<Player*>(m_caster)->GetSkillValue(SKILL_FISHING);
+            if (skill < zone_skill)
+                result = SPELL_FAILED_MIN_SKILL;
+
             float x, y, z;
             // special code for fishing bobber (TARGET_LOCATION_CASTER_FISHING_SPOT), should not try to avoid objects
             // nor try to find ground level, but randomly vary in angle
             float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
             float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
-            SpellCastResult result = SPELL_CAST_OK;
             for (uint32 i = 0; i < 10; ++i)
             {
                 float dis = rand_norm_f() * (max_dis - min_dis) + min_dis;
@@ -2167,6 +2176,12 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, bool targ

                 GridMapLiquidData liqData;
                 if (!m_caster->GetTerrain()->IsInWater(x, y, m_caster->GetTerrain()->GetWaterLevel(x, y, m_caster->GetPositionZ()) - 1.0f, &liqData))
+                {
+                    result = SPELL_FAILED_TOO_SHALLOW;
+                    continue;
+                }
+
+                if (liqData.type_flags & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME))
                 {
                     result = SPELL_FAILED_NOT_FISHABLE;
                     continue;

Steps to Reproduce

1. 2. 3. 4.

Expected behavior

No response

Suggested Workaround

No response

Crash Log

No response

Core SHA1 Commit Hash

4aa81134be302fed4a22f1c2e01374e3c3

Database SHA1 Commit Hash

87d213957c5f6d4e2e3679eaf81986eb43e32525

Operating System

windows 10

Client Version

2.4.3 (The Burning Crusade)

kelbren commented 3 weeks ago

Tested the changes, It works, gives this error message. "Your skill is not high enough. REQUIRES UNKNOWN (0)" change result = SPELL_FAILED_MIN_SKILL; to result = SPELL_FAILED_FISHING_TOO_LOW; and modify the SendCastResult function to report actual required skill level.

    case SPELL_FAILED_FISHING_TOO_LOW:
    {
        uint32 zone, subzone;
        caster->GetZoneAndAreaId(zone, subzone);
        int32 zone_skill = sObjectMgr.GetFishingBaseSkillLevel(subzone);
        if (!zone_skill)
            zone_skill = sObjectMgr.GetFishingBaseSkillLevel(zone);         
        data << zone_skill;  // required fishing skill
       break;
   }

this reports the correct fishing skill requirement.

Thanks!

al3xc1985 commented 3 weeks ago

I have to summon the divinity: @killerwife oh wise one! Can u take a look at this pls and tell us your point of view? ty @kelbren

insunaa commented 3 weeks ago

I also got the "too shallow" part wrong, after re-reading the original I think that check was for whether or not the bobber lands in water at all.

good addition, kelbren