diff --git a/sql/custom/world/2026_10_14_00_world_classic_tauren_cultivation.sql b/sql/custom/world/2026_10_14_00_world_classic_tauren_cultivation.sql new file mode 100644 index 0000000000..7caa461dc5 --- /dev/null +++ b/sql/custom/world/2026_10_14_00_world_classic_tauren_cultivation.sql @@ -0,0 +1,16 @@ +-- Classic 1.60: Tauren racial Cultivation (20552 -> 1312643): the duplicate ("cultivated") herb of every herb we spawn. +-- Official twins seen in the sniffs: Peacebloom 1618 -> 657382, Wilted Peacebloom 656160 -> 657454 (same name, model and loot as +-- the herb, lock 4522 = key spell 1312650, so no Herbalism skill is needed, Data17 = 158458 like theirs). The other herbs were not +-- sniffed: their twins are copies of the herb with the same two changes, entry 9700000 + herb (Stunted Silverleaf 656161 -> 9556161). +-- classic_spell_tauren_cultivate_herb finds a herb's twin by model + loot. Safe to run again. +DELETE FROM `gameobject_template` WHERE `entry` IN (9701617,9701619,9701620,9701621,9701622,9701623,9701628,9702041,9702042,9702043,9702044,9702045,9702046,9702866,9703724,9703725,9703726,9703727,9703729,9703730,9842140,9842141,9842142,9842143,9842144,9842145,9876583,9876584,9876586,9876587,9876588,9876589,9876636,9876637,9876638,9876639,9876640,9876641,9876642,9880164,9880165,9880166,9880167,9880168,9556161); +INSERT INTO `gameobject_template` (`entry`,`type`,`displayId`,`name`,`IconName`,`castBarCaption`,`unk1`,`size`,`Data0`,`Data1`,`Data2`,`Data3`,`Data4`,`Data5`,`Data6`,`Data7`,`Data8`,`Data9`,`Data10`,`Data11`,`Data12`,`Data13`,`Data14`,`Data15`,`Data16`,`Data17`,`Data18`,`Data19`,`Data20`,`Data21`,`Data22`,`Data23`,`Data24`,`Data25`,`Data26`,`Data27`,`Data28`,`Data29`,`Data30`,`Data31`,`Data32`,`Data33`,`Data34`,`ContentTuningId`,`RequiredLevel`,`AIName`,`ScriptName`,`StringId`,`VerifiedBuild`) +SELECT CASE `entry` WHEN 1617 THEN 9701617 WHEN 1619 THEN 9701619 WHEN 1620 THEN 9701620 WHEN 1621 THEN 9701621 WHEN 1622 THEN 9701622 WHEN 1623 THEN 9701623 WHEN 1628 THEN 9701628 WHEN 2041 THEN 9702041 WHEN 2042 THEN 9702042 WHEN 2043 THEN 9702043 WHEN 2044 THEN 9702044 WHEN 2045 THEN 9702045 WHEN 2046 THEN 9702046 WHEN 2866 THEN 9702866 WHEN 3724 THEN 9703724 WHEN 3725 THEN 9703725 WHEN 3726 THEN 9703726 WHEN 3727 THEN 9703727 WHEN 3729 THEN 9703729 WHEN 3730 THEN 9703730 WHEN 142140 THEN 9842140 WHEN 142141 THEN 9842141 WHEN 142142 THEN 9842142 WHEN 142143 THEN 9842143 WHEN 142144 THEN 9842144 WHEN 142145 THEN 9842145 WHEN 176583 THEN 9876583 WHEN 176584 THEN 9876584 WHEN 176586 THEN 9876586 WHEN 176587 THEN 9876587 WHEN 176588 THEN 9876588 WHEN 176589 THEN 9876589 WHEN 176636 THEN 9876636 WHEN 176637 THEN 9876637 WHEN 176638 THEN 9876638 WHEN 176639 THEN 9876639 WHEN 176640 THEN 9876640 WHEN 176641 THEN 9876641 WHEN 176642 THEN 9876642 WHEN 180164 THEN 9880164 WHEN 180165 THEN 9880165 WHEN 180166 THEN 9880166 WHEN 180167 THEN 9880167 WHEN 180168 THEN 9880168 WHEN 656161 THEN 9556161 END, `type`, `displayId`, `name`, `IconName`, `castBarCaption`, `unk1`, `size`, 4522, `Data1`, `Data2`, `Data3`, `Data4`, `Data5`, `Data6`, `Data7`, `Data8`, `Data9`, `Data10`, `Data11`, `Data12`, `Data13`, `Data14`, `Data15`, `Data16`, 158458, `Data18`, `Data19`, `Data20`, `Data21`, `Data22`, `Data23`, `Data24`, `Data25`, `Data26`, `Data27`, `Data28`, `Data29`, `Data30`, `Data31`, `Data32`, `Data33`, `Data34`, `ContentTuningId`, `RequiredLevel`, '', '', '', 0 FROM `gameobject_template` WHERE `entry` IN (1617,1619,1620,1621,1622,1623,1628,2041,2042,2043,2044,2045,2046,2866,3724,3725,3726,3727,3729,3730,142140,142141,142142,142143,142144,142145,176583,176584,176586,176587,176588,176589,176636,176637,176638,176639,176640,176641,176642,180164,180165,180166,180167,180168,656161); +DELETE FROM `gameobject_template_addon` WHERE `entry` IN (9701617,9701619,9701620,9701621,9701622,9701623,9701628,9702041,9702042,9702043,9702044,9702045,9702046,9702866,9703724,9703725,9703726,9703727,9703729,9703730,9842140,9842141,9842142,9842143,9842144,9842145,9876583,9876584,9876586,9876587,9876588,9876589,9876636,9876637,9876638,9876639,9876640,9876641,9876642,9880164,9880165,9880166,9880167,9880168,9556161); +INSERT INTO `gameobject_template_addon` (`entry`,`faction`,`flags`,`mingold`,`maxgold`,`artkit0`,`artkit1`,`artkit2`,`artkit3`,`artkit4`,`WorldEffectID`,`AIAnimKitID`) +SELECT CASE `entry` WHEN 1617 THEN 9701617 WHEN 1619 THEN 9701619 WHEN 1620 THEN 9701620 WHEN 1621 THEN 9701621 WHEN 1622 THEN 9701622 WHEN 1623 THEN 9701623 WHEN 1628 THEN 9701628 WHEN 2041 THEN 9702041 WHEN 2042 THEN 9702042 WHEN 2043 THEN 9702043 WHEN 2044 THEN 9702044 WHEN 2045 THEN 9702045 WHEN 2046 THEN 9702046 WHEN 2866 THEN 9702866 WHEN 3724 THEN 9703724 WHEN 3725 THEN 9703725 WHEN 3726 THEN 9703726 WHEN 3727 THEN 9703727 WHEN 3729 THEN 9703729 WHEN 3730 THEN 9703730 WHEN 142140 THEN 9842140 WHEN 142141 THEN 9842141 WHEN 142142 THEN 9842142 WHEN 142143 THEN 9842143 WHEN 142144 THEN 9842144 WHEN 142145 THEN 9842145 WHEN 176583 THEN 9876583 WHEN 176584 THEN 9876584 WHEN 176586 THEN 9876586 WHEN 176587 THEN 9876587 WHEN 176588 THEN 9876588 WHEN 176589 THEN 9876589 WHEN 176636 THEN 9876636 WHEN 176637 THEN 9876637 WHEN 176638 THEN 9876638 WHEN 176639 THEN 9876639 WHEN 176640 THEN 9876640 WHEN 176641 THEN 9876641 WHEN 176642 THEN 9876642 WHEN 180164 THEN 9880164 WHEN 180165 THEN 9880165 WHEN 180166 THEN 9880166 WHEN 180167 THEN 9880167 WHEN 180168 THEN 9880168 WHEN 656161 THEN 9556161 END, `faction`, `flags`, `mingold`, `maxgold`, `artkit0`, `artkit1`, `artkit2`, `artkit3`, `artkit4`, `WorldEffectID`, `AIAnimKitID` FROM `gameobject_template_addon` WHERE `entry` IN (1617,1619,1620,1621,1622,1623,1628,2041,2042,2043,2044,2045,2046,2866,3724,3725,3726,3727,3729,3730,142140,142141,142142,142143,142144,142145,176583,176584,176586,176587,176588,176589,176636,176637,176638,176639,176640,176641,176642,180164,180165,180166,180167,180168,656161); + +DELETE FROM `spell_script_names` WHERE `spell_id` IN (20552, 1312643); +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(20552, 'classic_spell_tauren_cultivation'), +(1312643, 'classic_spell_tauren_cultivate_herb'); diff --git a/src/server/scripts/Custom/Classic/world/classic_spell_scripts.cpp b/src/server/scripts/Custom/Classic/world/classic_spell_scripts.cpp index eed7080646..5abbc5148f 100644 --- a/src/server/scripts/Custom/Classic/world/classic_spell_scripts.cpp +++ b/src/server/scripts/Custom/Classic/world/classic_spell_scripts.cpp @@ -27,11 +27,14 @@ #include "DB2Stores.h" #include "Formulas.h" #include "GameObject.h" +#include "GameTime.h" #include "GridNotifiersImpl.h" #include "Item.h" #include "ItemTemplate.h" #include "Map.h" #include "ObjectAccessor.h" +#include "ObjectMgr.h" +#include "PhasingHandler.h" #include "Player.h" #include "QuestDef.h" #include "SpellAuraEffects.h" @@ -41,6 +44,8 @@ #include "ThreatManager.h" #include "Unit.h" #include "WorldSession.h" +#include +#include /*###### ## classic_spell_ground_area_damage @@ -1011,8 +1016,155 @@ public: } }; +// Tauren racial Cultivation (1.60): "Cultivate a nearby herb, growing a duplicate you can harvest without requiring Herbalism skill. +// Each herb may only be cultivated once." Official sniffs (2026-09-28, 2026-10-01): the spellbook spell 20552 (instant, dummy on game +// objects within 5 yd) makes the server start 1312643 (3 sec cast) on the herb; when it completes a duplicate herb appears on the same +// spot, created by the player: same model and loot, lock 4522 = key spell 1312650 (open lock without skill, the player does not know +// it; Player allows lock key spells of the target). Peacebloom 1618 -> 657382, Wilted Peacebloom 656160 -> 657454; the other twins are +// made by 2026_10_14_00_world_classic_tauren_cultivation.sql. A twin is found by model + loot. +namespace ClassicCultivation +{ + static constexpr uint32 SPELL_CULTIVATE_HERB = 1312643; + static constexpr uint32 LOCK_CULTIVATED_HERB = 4522; + static constexpr float SEARCH_RANGE = 5.0f; + static constexpr Seconds TWIN_DURATION = 5min; + static constexpr Seconds HERB_COOLDOWN = 15min; // "each herb may only be cultivated once" (until it has been picked and regrown) + + static bool IsHerbalismLock(uint32 lockId) + { + LockEntry const* lock = sLockStore.LookupEntry(lockId); + if (!lock) + return false; + for (uint8 i = 0; i < MAX_LOCK_CASE; ++i) + if (lock->Type[i] == LOCK_KEY_SKILL && lock->Index[i] == LOCKTYPE_HERBALISM) + return true; + return false; + } + + // herb (model, loot) -> twin entry + static uint32 GetTwinEntry(GameObjectTemplate const* herb) + { + static std::unordered_map const twins = [] + { + std::unordered_map map; + for (auto const& [entry, goInfo] : sObjectMgr->GetGameObjectTemplates()) + if (goInfo.type == GAMEOBJECT_TYPE_CHEST && goInfo.chest.open == LOCK_CULTIVATED_HERB) + map.emplace(uint64(goInfo.displayId) << 32 | goInfo.chest.chestLoot, entry); + return map; + }(); + if (!herb || herb->type != GAMEOBJECT_TYPE_CHEST || !IsHerbalismLock(herb->chest.open)) + return 0; + auto itr = twins.find(uint64(herb->displayId) << 32 | herb->chest.chestLoot); + return itr != twins.end() ? itr->second : 0; + } + + static std::unordered_map CultivatedHerbs; + static std::mutex CultivatedHerbsLock; + + static bool WasCultivated(ObjectGuid const& herb) + { + std::lock_guard guard(CultivatedHerbsLock); + auto itr = CultivatedHerbs.find(herb); + if (itr == CultivatedHerbs.end()) + return false; + if (GameTime::Now() - itr->second < HERB_COOLDOWN) + return true; + CultivatedHerbs.erase(itr); + return false; + } + + static void MarkCultivated(ObjectGuid const& herb) + { + std::lock_guard guard(CultivatedHerbsLock); + CultivatedHerbs[herb] = GameTime::Now(); + } + + static bool CanCultivate(GameObject const* go) + { + return go && go->isSpawned() && go->GetGoState() == GO_STATE_READY && !go->GetOwnerGUID() + && GetTwinEntry(go->GetGOInfo()) && !WasCultivated(go->GetGUID()); + } + + static GameObject* FindHerb(Unit* caster) + { + std::list objects; + Trinity::AllWorldObjectsInRange check(caster, SEARCH_RANGE); + Trinity::GameObjectListSearcher searcher(caster, objects, check); + Cell::VisitGridObjects(caster, searcher, SEARCH_RANGE); + GameObject* best = nullptr; + for (GameObject* go : objects) + if (CanCultivate(go) && (!best || caster->GetExactDist2dSq(go) < caster->GetExactDist2dSq(best))) + best = go; + return best; + } +} + +// 20552 - Cultivation (Tauren racial, spellbook): starts Cultivate (1312643) on the nearest herb within 5 yd +class classic_spell_tauren_cultivation : public SpellScript +{ + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ ClassicCultivation::SPELL_CULTIVATE_HERB }); + } + + SpellCastResult CheckCast() + { + return ClassicCultivation::FindHerb(GetCaster()) ? SPELL_CAST_OK : SPELL_FAILED_NO_VALID_TARGETS; + } + + void HandleAfterCast() + { + if (GameObject* herb = ClassicCultivation::FindHerb(GetCaster())) + GetCaster()->CastSpell(herb, ClassicCultivation::SPELL_CULTIVATE_HERB, CastSpellExtraArgs(TRIGGERED_IGNORE_GCD)); + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(classic_spell_tauren_cultivation::CheckCast); + AfterCast += SpellCastFn(classic_spell_tauren_cultivation::HandleAfterCast); + } +}; + +// 1312643 - Cultivate: the herb's twin grows on the same spot, for the caster only +class classic_spell_tauren_cultivate_herb : public SpellScript +{ + SpellCastResult CheckCast() + { + GameObject* herb = GetExplTargetGObj(); + return ClassicCultivation::CanCultivate(herb) ? SPELL_CAST_OK : SPELL_FAILED_BAD_TARGETS; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + GameObject* herb = GetHitGObj(); + if (!caster || !ClassicCultivation::CanCultivate(herb)) + return; + + uint32 twinEntry = ClassicCultivation::GetTwinEntry(herb->GetGOInfo()); + GameObject* twin = GameObject::CreateGameObject(twinEntry, herb->GetMap(), *herb, herb->GetLocalRotation(), 255, GO_STATE_READY); + if (!twin) + return; + + ClassicCultivation::MarkCultivated(herb->GetGUID()); + PhasingHandler::InheritPhaseShift(twin, caster); + twin->SetPrivateObjectOwner(caster->GetGUID()); + twin->SetRespawnTime(ClassicCultivation::TWIN_DURATION.count()); + caster->AddGameObject(twin); + herb->GetMap()->AddToMap(twin); + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(classic_spell_tauren_cultivate_herb::CheckCast); + OnEffectHitTarget += SpellEffectFn(classic_spell_tauren_cultivate_herb::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + void AddSC_classic_spell_scripts() { + RegisterSpellScript(classic_spell_tauren_cultivation); + RegisterSpellScript(classic_spell_tauren_cultivate_herb); new classic_unit_tigers_fury(); RegisterSpellScript(classic_spell_pri_vampiric_embrace); RegisterSpellScript(classic_spell_pal_consecration);