mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 08:33:47 +00:00
fix(Scripts/Midsummer): Improve Torch Catching based on sniffs (#18071)
- Update creature 26188 '[PH] Torch Catching Target Bunny' with sniffed values - correctly randomize torch target positions
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
-- Update creature 26188 '[PH] Torch Catching Target Bunny' with sniffed values
|
||||
-- updated spawns
|
||||
DELETE FROM `creature` WHERE (`id1` = 26188) AND (`guid` IN (245595, 245600, 245604, 245606, 245610, 245614, 245635, 245640));
|
||||
INSERT INTO `creature` (`guid`, `id1`, `map`, `spawnMask`, `phaseMask`, `equipment_id`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecs`, `wander_distance`, `MovementType`, `npcflag`, `unit_flags`, `dynamicflags`, `ScriptName`, `VerifiedBuild`, `CreateObject`, `Comment`) VALUES
|
||||
(245595, 26188, 1, 1, 1, 0, 8687.6015625, 971.4619140625, 11.0921945571899414, 3.351032257080078125, 120, 0, 0, 0, 0, 0, "", 50063, 1, NULL),
|
||||
(245600, 26188, 1, 1, 1, 0, -1026.82470703125, 284.664947509765625, 135.8292694091796875, 5.113814830780029296, 120, 0, 0, 0, 0, 0, "", 50172, 1, NULL),
|
||||
(245604, 26188, 1, 1, 1, 0, 1930.842041015625, -4341.5693359375, 19.84100914001464843, 5.445427417755126953, 120, 0, 0, 0, 0, 0, "", 50172, 1, NULL),
|
||||
(245606, 26188, 0, 1, 1, 0, 1826.7586669921875, 254.811309814453125, 59.9133148193359375, 0.680678427219390869, 120, 0, 0, 0, 0, 0, "", 50063, 1, NULL),
|
||||
(245610, 26188, 0, 1, 1, 0, -4716.79296875, -1203.8480224609375, 501.74273681640625, 3.019419670104980468, 120, 0, 0, 0, 0, 0, "", 50063, 1, NULL),
|
||||
(245614, 26188, 0, 1, 1, 0, -8814.5283203125, 876.83599853515625, 98.82147216796875, 3.96189737319946289, 120, 0, 0, 0, 0, 0, "", 50063, 1, NULL),
|
||||
(245635, 26188, 530, 1, 1, 0, 9816.404296875, -7269.10205078125, 26.31508064270019531, 4.485496044158935546, 120, 0, 0, 0, 0, 0, "", 50063, 1, NULL),
|
||||
(245640, 26188, 530, 1, 1, 0, -3769, -11506.2119140625, -134.381103515625, 3.333578824996948242, 120, 0, 0, 0, 0, 0, "", 50063, 1, NULL);
|
||||
|
||||
-- remove duplicate spawns
|
||||
DELETE FROM `creature` WHERE (`id1` = 26188) AND (`guid` IN (245611, 245609, 245612, 245594, 245615, 245613, 245608, 245607, 245601, 245598, 245599, 245602, 245605, 245603, 245596, 245597, 245639, 245641, 245638, 245636, 245637, 245634));
|
||||
DELETE FROM `creature_addon` WHERE (`guid` IN (245611, 245609, 245612, 245594, 245615, 245613, 245608, 245607, 245601, 245598, 245599, 245602, 245605, 245603, 245596, 245597, 245639, 245641, 245638, 245636, 245637, 245634));
|
||||
DELETE FROM `game_event_creature` WHERE (`guid` IN (245611, 245609, 245612, 245594, 245615, 245613, 245608, 245607, 245601, 245598, 245599, 245602, 245605, 245603, 245596, 245597, 245639, 245641, 245638, 245636, 245637, 245634));
|
||||
|
||||
-- enable all spawns for eventEntry 1
|
||||
DELETE FROM `game_event_creature` WHERE (`eventEntry` = 1) AND (`guid` IN (SELECT `guid` FROM `creature` WHERE `id1` = 26188));
|
||||
INSERT INTO `game_event_creature` (SELECT 1, `guid` FROM `creature` WHERE `id1` = 26188);
|
||||
@@ -1014,44 +1014,29 @@ class spell_midsummer_fling_torch : public SpellScript
|
||||
bool handled;
|
||||
bool Load() override { handled = false; return true; }
|
||||
|
||||
SpellCastResult CheckCast()
|
||||
{
|
||||
GetCaster()->GetCreaturesWithEntryInRange(_crList, 100.0f, NPC_TORCH_TARGET);
|
||||
if (_crList.empty())
|
||||
{
|
||||
return SPELL_FAILED_NOT_HERE;
|
||||
}
|
||||
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
void ThrowNextTorch(Unit* caster)
|
||||
{
|
||||
uint8 rand = urand(0, _crList.size() - 1);
|
||||
Position pos;
|
||||
pos.Relocate(0.0f, 0.0f, 0.0f);
|
||||
for (std::list<Creature*>::const_iterator itr = _crList.begin(); itr != _crList.end(); ++itr, --rand)
|
||||
{
|
||||
if (caster->GetDistance(*itr) < 5)
|
||||
{
|
||||
if (!rand)
|
||||
rand++;
|
||||
continue;
|
||||
}
|
||||
Creature* bunny = caster->FindNearestCreature(NPC_TORCH_TARGET, 100.0f);
|
||||
|
||||
if (!rand)
|
||||
{
|
||||
pos.Relocate(*itr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bunny)
|
||||
return;
|
||||
|
||||
// we have any pos
|
||||
if (pos.GetPositionX())
|
||||
{
|
||||
caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLING_TORCH, true);
|
||||
caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_TORCH_SHADOW, true);
|
||||
}
|
||||
// targets are located on a circle with fixed radius around the target bunny
|
||||
// first target is chosen randomly anywhere on the circle
|
||||
// next target is chosen on the opposite half of the circle
|
||||
// so a minimum flight duration of the torch is guaranteed
|
||||
float angle = 0.0f;
|
||||
if (GetSpellInfo()->Id == SPELL_FLING_TORCH_DUMMY)
|
||||
angle = frand(-1.0f * M_PI, 1.0f * M_PI); // full circle
|
||||
else
|
||||
angle = frand(-0.5f * M_PI, 0.5f * M_PI); // half circle
|
||||
|
||||
Position pos = bunny->GetPosition();
|
||||
pos.SetOrientation(caster->GetPosition().GetAbsoluteAngle(pos));
|
||||
pos.RelocatePolarOffset(angle, 8.0f); // radius is sniffed value
|
||||
|
||||
caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLING_TORCH, true);
|
||||
caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_TORCH_SHADOW, true);
|
||||
}
|
||||
|
||||
void HandleFinish()
|
||||
@@ -1108,15 +1093,11 @@ class spell_midsummer_fling_torch : public SpellScript
|
||||
void Register() override
|
||||
{
|
||||
AfterCast += SpellCastFn(spell_midsummer_fling_torch::HandleFinish);
|
||||
OnCheckCast += SpellCheckCastFn(spell_midsummer_fling_torch::CheckCast);
|
||||
if (m_scriptSpellId == SPELL_JUGGLE_TORCH)
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_midsummer_fling_torch::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<Creature*> _crList;
|
||||
};
|
||||
|
||||
enum eJuggle
|
||||
|
||||
Reference in New Issue
Block a user