Scripts/Spells: Fixed Friend or Fowl achievement

This commit is contained in:
Shauren
2011-05-07 11:40:15 +02:00
parent b087741959
commit 49aeb3ae5a
4 changed files with 87 additions and 0 deletions

View File

@@ -1892,6 +1892,7 @@ INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
( 69892, 'spell_generic_clone_weapon'),
( 57593, 'spell_generic_clone_weapon'),
( 52408, 'spell_gen_seaforium_blast'),
( 25281, 'spell_gen_turkey_marker'),
-- instances
-- Black Temple
( 41475, 'spell_boss_lady_malande_shield'),

View File

@@ -0,0 +1,7 @@
UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry` IN (23801,24746,29594);
DELETE FROM `smart_scripts` WHERE `entryorguid` IN (23801,24746,29594);
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
(23801,0,0,0,6,0,100,1,0,0,0,0,85,25281,2,0,0,0,0,7,0,0,0,0,0,0,0,'Turkey - Cast Marker on death'),
(24746,0,0,0,6,0,100,1,0,0,0,0,85,25281,2,0,0,0,0,7,0,0,0,0,0,0,0,'Fjord Turkey - Cast Marker on death'),
(29594,0,0,0,6,0,100,1,0,0,0,0,85,25281,2,0,0,0,0,7,0,0,0,0,0,0,0,'Angry Turkey - Cast Marker on death');

View File

@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_turkey_marker';
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(25281, 'spell_gen_turkey_marker');

View File

@@ -986,6 +986,81 @@ class spell_gen_seaforium_blast : public SpellScriptLoader
}
};
enum FriendOrFowl
{
SPELL_TURKEY_VENGEANCE = 25285,
};
class spell_gen_turkey_marker : public SpellScriptLoader
{
public:
spell_gen_turkey_marker() : SpellScriptLoader("spell_gen_turkey_marker") { }
class spell_gen_turkey_marker_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_turkey_marker_AuraScript);
void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
// store stack apply times, so we can pop them while they expire
_applyTimes.push_back(getMSTime());
// on stack 15 cast the achievement crediting spell
if (GetStackAmount() >= 15)
GetTarget()->CastSpell(GetTarget(), SPELL_TURKEY_VENGEANCE, true, NULL, aurEff, GetCasterGUID());
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_STACK)
return;
// find our new aura which replaces this one aura is inserted to m_ownedAuras before old removal takes place
Aura* newAura = GetTarget()->GetOwnedAura(GetId(), 0, 0, 0, GetAura());
// this should never happen
if (!newAura)
return;
std::list<AuraScript*> const& loadedScripts = newAura->m_loadedScripts;
// find the new aura's script and give it our stored stack apply times
for (std::list<AuraScript*>::const_iterator itr = loadedScripts.begin(); itr != loadedScripts.end(); ++itr)
{
if (spell_gen_turkey_marker_AuraScript* scr = dynamic_cast<spell_gen_turkey_marker_AuraScript*>(*itr))
{
scr->_applyTimes.splice(scr->_applyTimes.begin(), _applyTimes);
break;
}
}
}
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
if (_applyTimes.empty())
return;
// pop stack if it expired for us
if (_applyTimes.front() + GetMaxDuration() < getMSTime())
if (ModStackAmount(-1))
GetTarget()->RemoveOwnedAura(GetAura(), AURA_REMOVE_BY_EXPIRE);
}
void Register()
{
OnEffectApply += AuraEffectApplyFn(spell_gen_turkey_marker_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_turkey_marker_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_turkey_marker_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
std::list<uint32> _applyTimes;
};
AuraScript* GetAuraScript() const
{
return new spell_gen_turkey_marker_AuraScript();
}
};
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -1009,4 +1084,5 @@ void AddSC_generic_spell_scripts()
new spell_generic_clone();
new spell_generic_clone_weapon();
new spell_gen_seaforium_blast();
new spell_gen_turkey_marker();
}