DragonFire/Dragon — Issue #944: Current Achievments - FIX - Class VIB
Author: nelegalno
Created: 2012-02-09 17:02:55+00:00
State: open

```SQL
-- Love is in the Air
UPDATE `achievement_criteria_data` SET `value1`=423 WHERE `value1`=335 AND `type`=16;

-- A Friendly Chat... (24576, 24657)
-- Snivel Rustrocket set gossip flag
UPDATE `creature_template` SET `npcflag` = 1, `AIName`='SmartAI' WHERE `entry` = 37715;

-- Quest credit SAI
DELETE FROM `smart_scripts` WHERE (`entryorguid`=37715 AND `source_type`=0);
INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(37715,0,0,0,62,0,100,0,10946,0,0,0,11,70646,2,0,0,0,0,7,0,0,0,0,0,0,0, "Snivel Rustrocket - on gosip 10947 - cast Love - Create Snivel's Ledger");

-- Gossip option conditions
DELETE FROM `conditions` WHERE (`SourceTypeOrReferenceId`=15 AND `SourceGroup`=10929);
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(15,10929,0,0,9,24576,0,0,0,'','Show gossip only if plaer have A Friendly Chat... Horde quest'),
(15,10929,0,0,9,24657,0,0,0,'','Show gossip only if plaer have A Friendly Chat... Alliance quest');

-- Fix achievement "Lonely?"
UPDATE `gameobject_template` SET `flags` = `flags` | 32, `AIName` = 'SmartGameObjectAI' WHERE `entry` = 187267;

DELETE FROM `spell_script_names` WHERE `spell_id` = 45102;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(45102, 'spell_love_is_in_the_air_romantic_picnic');

DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` IN (45119, 45103, 45114);
INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES
(13, 0, 45119, 0, 0, 18, 0, 187267, 0, 0, '', 'Holiday - Valentine - Romantic Picnic Near Basket Check - Target Romantic Basket'),
(13, 0, 45103, 0, 0, 18, 1, 0, 0, 0, '', 'Holiday - Valentine - Romantic Picnic Meal Periodic - Target Players'),
(13, 0, 45114, 0, 0, 18, 1, 0, 0, 0, '', 'Holiday - Valentine - Romantic Picnic Meal Particle - Target Players');

DELETE FROM `smart_scripts` WHERE `entryorguid`=187267 AND `source_type`=1;
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(187267, 1, 0, 0, 60, 0, 100, 0, 3*60*1000, 3*60*1000, 0, 0, 99, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Picnic Basket - Despawn after 3 minutes');

DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (1291,5787,4071);
INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES
(5787, 6, 4395, 0, ''), -- Lonely? - Dalaran
(4071, 6, 4395, 0, ''); -- Lonely? - Dalaran

-- Missing Love is in the Air NPCs
SET @GUID := 40481; -- need 8

DELETE FROM `creature` WHERE `guid` BETWEEN @GUID AND @GUID+7 AND `id` IN (37887,38039,38040,38066,38325,38293);
INSERT INTO `creature` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`modelid`,`equipment_id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`currentwaypoint`,`curhealth`,`curmana`,`MovementType`,`npcflag`,`unit_flags`,`dynamicflags`) VALUES
(@GUID+0,37887,0,1,1,0,0,-8864.01,635.646,96.0818,1.97249,300,0,0,42,0,0,2,0,8), -- Kwee Q. Peddlefeet
(@GUID+1,38039,1,1,1,0,0,9871.16,2488.28,1315.88,0.547356,300,0,0,42,0,0,2,0,8), -- Kwee Q. Peddlefeet
(@GUID+2,38040,530,1,1,0,0,-4010.12,-11846.9,0.1352,5.42082,300,0,0,42,0,0,2,0,8), -- Kwee Q. Peddlefeet
(@GUID+3,38040,0,1,1,0,0,-4915.43,-979.532,501.448,2.31443,300,0,0,42,0,0,2,0,8), -- Kwee Q. Peddlefeet
(@GUID+4,38066,0,1,1,0,0,-8867.86,652.647,97.0113,4.84704,300,0,0,42,0,0,2,0,8), -- Inspector Snip Snagglebolt
(@GUID+5,38325,0,1,1,0,0,-8881.19,669.006,105.834,0.696214,300,0,0,42,0,0,2,0,8), -- Marion Sutton
(@GUID+6,38293,0,1,1,0,0,-4932.9,-995.348,501.441,0.7201,300,0,0,42,0,0,2,0,8), -- Junior Inspector
(@GUID+7,38293,1,1,1,0,0,9885.37,2494.31,1315.92,3.01351,300,0,0,42,0,0,2,0,8); -- Junior Inspector

DELETE FROM `game_event_creature` WHERE `eventEntry`=8 AND `guid` BETWEEN @GUID AND @GUID+7;
INSERT INTO `game_event_creature` (`guid`,`eventEntry`) VALUES
(@GUID+0,8),
(@GUID+1,8),
(@GUID+2,8),
(@GUID+3,8),
(@GUID+4,8),
(@GUID+5,8),
(@GUID+6,8),
(@GUID+7,8);

-- Template updates
UPDATE `creature_template` SET `npcflag`=`npcflag`|3,`unit_flags`=`unit_flags`|32768,`speed_run`=1 WHERE `name`='Kwee Q. Peddlefeet' AND `IconName`!=NULL; -- Kwee Q. Peddlefeet
UPDATE `creature_template` SET `npcflag`=`npcflag`|3,`unit_flags`=`unit_flags`|512 WHERE `entry`=38066; -- Inspector Snip Snagglebolt
UPDATE `creature_template` SET `npcflag`=`npcflag`|2 WHERE `entry`=38325; -- Marion Sutton
UPDATE `creature_template` SET `npcflag`=`npcflag`|2 WHERE `entry`=38293; -- Junior Inspector (NS)

-- Model data
UPDATE `creature_model_info` SET `bounding_radius`=0.29,`combat_reach`=2.5,`gender`=0 WHERE `modelid`=15990; -- Kwee Q. Peddlefeet
UPDATE `creature_model_info` SET `bounding_radius`=0.306,`combat_reach`=1.5,`gender`=0 WHERE `modelid`=30728; -- Inspector Snip Snagglebolt
UPDATE `creature_model_info` SET `bounding_radius`=0.208,`combat_reach`=1.5,`gender`=0 WHERE `modelid`=31040; -- Marion Sutton

-- Addon data
DELETE FROM `creature_template_addon` WHERE `entry` IN (37887,38039,38040,38066,38325);
INSERT INTO `creature_template_addon` (`entry`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES
(37887,0,0,1,0, NULL), -- Kwee Q. Peddlefeet
(38039,0,0,1,0, NULL), -- Kwee Q. Peddlefeet
(38040,0,0,1,0, NULL), -- Kwee Q. Peddlefeet
(38066,0,0,257,0, NULL), -- Inspector Snip Snagglebolt
(38325,0,1,1,0, NULL); -- Marion Sutton

-- Gossip, unfinished
DELETE FROM `gossip_menu_option` WHERE `menu_id`=10948 AND `id`=0;
INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `box_coded`, `box_money`, `box_text`) VALUES
(10948, 0, 0, 'I''d like a Lovely Charm Collector''s Kit.', 0, 0, '');

-- Criteria data for "I Pitied The Fool"
DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (6343, 6344, 6345, 6346, 6347);
INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES
(6343,6,4197,0,''), -- Wintergrasp
(6343,1,16111,0,''), -- target Love Fool
(6344,6,2177,0,''), -- Battle Ring
(6344,1,16111,0,''), -- target Love Fool
(6345,6,3421,0,''), -- Blacksmith
(6345,1,16111,0,''), -- target Love Fool
(6346,6,4100,0,''), -- The Culling of Stratholme
(6346,1,16111,0,''), -- target Love Fool
(6347,6,3456,0,''), -- Naxxramas
(6347,1,16111,0,''); -- target Love Fool

-- Lunar festival: Rocket Clusters placed near Omen's summon place (Moonglade)
SET @CLUSTER := 180874;
SET @LUNARFESTIVAL := 7;

DELETE FROM `gameobject` WHERE `id`=@CLUSTER AND `guid` IN (230,231);
INSERT INTO `gameobject` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`) VALUES
(230,@CLUSTER,1,1,1,7531.662,-2851.228,458.9172),
(231,@CLUSTER,1,1,1,7561.145,-2872.45,461.0998);

DELETE FROM `game_event_gameobject` WHERE `guid` IN (230,231) AND `eventEntry`=@LUNARFESTIVAL;
INSERT INTO `game_event_gameobject` (`eventEntry`,`guid`) VALUES
(@LUNARFESTIVAL,230),
(@LUNARFESTIVAL,231);

-- Fix quests Chrushing the Crown
SET @ENTRY := 38035; -- Chemical Wagon
SET @SPELL1 := 71599; -- Cosmetic - Explosion (Chemical Wagon)
SET @SPELL2 := 71597; -- Cosmetic - Low Poly Fire (with Sound)

DELETE FROM `conditions` WHERE `SourceEntry`=@SPELL1 AND `SourceTypeOrReferenceId`=13 AND `ConditionTypeOrReference`=18;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`Comment`) VALUES
(13,@SPELL1,18,1,@ENTRY, 'Chemical Wagon - Cosmetic - Explosion (Chemical Wagon)');

DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
UPDATE creature_template SET AIName='SmartAI' WHERE entry=@ENTRY;
INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(@ENTRY,0,0,1,8,0,100,0,@SPELL1,0,0,0,33,@ENTRY,0,0,0,0,0,7,0,0,0,0.0,0.0,0.0,0.0,"Chemical Wagon - Spell Hit - Credit"),
(@ENTRY,0,1,0,61,0,100,0,0,0,0,0,11,@SPELL2,2,0,0,0,0,0,0,0,0,0.0,0.0,0.0,0.0,"Chemical Wagon - Spell Hit - Cast Cosmetic - Low Poly Fire (with Sound)");

```

src/server/game/Scripting/ScriptLoader.cpp

```DIFF
@@ -39,6 +39,7 @@
void AddSC_quest_spell_scripts();
void AddSC_item_spell_scripts();
void AddSC_example_spell_scripts();
+void AddSC_holiday_spell_scripts();

void AddSC_SmartSCripts();

@@ -642,6 +643,7 @@ void AddSpellScripts()
AddSC_quest_spell_scripts();
AddSC_item_spell_scripts();
AddSC_example_spell_scripts();
+ AddSC_holiday_spell_scripts();
}

void AddCommandScripts()
```

src/server/scripts/Spells/CMakeLists.txt

```DIFF
@@ -23,6 +23,7 @@ set(scripts_STAT_SRCS
Spells/spell_mage.cpp
Spells/spell_paladin.cpp
Spells/spell_item.cpp
+ Spells/spell_holiday.cpp
)

message(" -> Prepared: Spells")
```

/src/server/scripts/Spells/spell_holiday.cpp

```CPP
/*
* Copyright (C) 2008-2012 TrinityCore
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/

/*
* Spells used in holidays/game events that do not fit any other category.
* Scriptnames in this file should be prefixed with "spell_#holidayname_".
*/

#include "ScriptPCH.h"

// 45102 Romantic Picnic
enum SpellsPicnic
{
SPELL_BASKET_CHECK = 45119, // Holiday - Valentine - Romantic Picnic Near Basket Check
SPELL_MEAL_PERIODIC = 45103, // Holiday - Valentine - Romantic Picnic Meal Periodic - effect dummy
SPELL_MEAL_EAT_VISUAL = 45120, // Holiday - Valentine - Romantic Picnic Meal Eat Visual
//SPELL_MEAL_PARTICLE = 45114, // Holiday - Valentine - Romantic Picnic Meal Particle - unused
SPELL_DRINK_VISUAL = 45121, // Holiday - Valentine - Romantic Picnic Drink Visual
SPELL_ROMANTIC_PICNIC_ACHIEV = 45123, // Romantic Picnic periodic = 5000
};

class spell_love_is_in_the_air_romantic_picnic : public SpellScriptLoader
{
public:
spell_love_is_in_the_air_romantic_picnic() : SpellScriptLoader("spell_love_is_in_the_air_romantic_picnic") { }

class spell_love_is_in_the_air_romantic_picnic_AuraScript : public AuraScript
{
PrepareAuraScript(spell_love_is_in_the_air_romantic_picnic_AuraScript);

void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetStandState(UNIT_STAND_STATE_SIT);
target->CastSpell(target, SPELL_MEAL_PERIODIC, false);
}

void OnPeriodic(AuraEffect const* /*aurEff*/)
{
// Every 5 seconds
Unit* target = GetTarget();
Unit* caster = GetCaster();

// If our player is no longer sit, remove all auras
if (target->getStandState() != UNIT_STAND_STATE_SIT)
{
target->RemoveAura(SPELL_ROMANTIC_PICNIC_ACHIEV);
target->RemoveAura(GetAura());
return;
}

target->CastSpell(target, SPELL_BASKET_CHECK, false); // unknown use, it targets Romantic Basket
target->CastSpell(target, RAND(SPELL_MEAL_EAT_VISUAL, SPELL_DRINK_VISUAL), false);

bool foundSomeone = false;
// For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123)
// required by achievement and "hearts" visual
std::list playerList;
Trinity::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE*2);
Trinity::PlayerListSearcher searcher(target, playerList, checker);
target->VisitNearbyWorldObject(INTERACTION_DISTANCE*2, searcher);
for (std::list::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
{
if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->getStandState() == UNIT_STAND_STATE_SIT)
{
if (caster)
{
caster->CastSpell(*itr, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
caster->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
}
foundSomeone = true;
// break;
}
}

if (!foundSomeone && target->HasAura(SPELL_ROMANTIC_PICNIC_ACHIEV))
target->RemoveAura(SPELL_ROMANTIC_PICNIC_ACHIEV);
}

void Register()
{
AfterEffectApply += AuraEffectApplyFn(spell_love_is_in_the_air_romantic_picnic_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_love_is_in_the_air_romantic_picnic_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
};

AuraScript* GetAuraScript() const
{
return new spell_love_is_in_the_air_romantic_picnic_AuraScript();
}
};

void AddSC_holiday_spell_scripts()
{
new spell_love_is_in_the_air_romantic_picnic();
}
```

src/server/game/Miscellaneous/SharedDefines.h

```DIFF
@@ -2623,7 +2623,7 @@ enum HolidayIds
HOLIDAY_HARVEST_FESTIVAL = 321,
HOLIDAY_HALLOWS_END = 324,
HOLIDAY_LUNAR_FESTIVAL = 327,
- HOLIDAY_LOVE_IS_IN_THE_AIR = 335,
+ // HOLIDAY_LOVE_IS_IN_THE_AIR = 335, unused/duplicated
HOLIDAY_FIRE_FESTIVAL = 341,
HOLIDAY_CALL_TO_ARMS_EY = 353,
HOLIDAY_BREWFEST = 372,
@@ -2636,6 +2636,7 @@ enum HolidayIds
HOLIDAY_WOTLK_LAUNCH = 406,
HOLIDAY_DAY_OF_DEAD = 409,
HOLIDAY_CALL_TO_ARMS_IC = 420,
+ HOLIDAY_LOVE_IS_IN_THE_AIR = 423,
HOLIDAY_KALU_AK_FISHING_DERBY = 424
};
```