Core/Spells: Fix 'Foam Sword Rack' mechanic

This commit is contained in:
Vincent-Michael
2012-08-27 19:57:26 +02:00
parent fe970b1c1e
commit 7e2d007e0d
3 changed files with 96 additions and 11 deletions
@@ -0,0 +1,4 @@
DELETE FROM `spell_script_names` WHERE `spell_id`IN (64142,62991);
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(64142,'spell_gen_upper_deck_create_foam_sword'),
(62991,'spell_gen_bonked');
-11
View File
@@ -4281,17 +4281,6 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
unitTarget->CastSpell(unitTarget, spellTarget[urand(0, 4)], true);
break;
}
case 64142: // Upper Deck - Create Foam Sword
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = unitTarget->ToPlayer();
static uint32 const itemId[] = {45061, 45176, 45177, 45178, 45179, 0};
// player can only have one of these items
for (uint32 const* itr = &itemId[0]; *itr; ++itr)
if (player->HasItemCount(*itr, 1, true))
return;
DoCreateItem(effIndex, itemId[urand(0, 4)]);
return;
}
break;
}
@@ -3076,6 +3076,96 @@ class spell_gen_mount : public SpellScriptLoader
uint32 _mount310;
};
enum FoamSword
{
ITEM_FOAM_SWORD_GREEN = 45061,
ITEM_FOAM_SWORD_PINK = 45176,
ITEM_FOAM_SWORD_BLUE = 45177,
ITEM_FOAM_SWORD_RED = 45178,
ITEM_FOAM_SWORD_YELLOW = 45179,
SPELL_BONKED = 62991,
SPELL_FOAM_SWORD_DEFEAT = 62994,
SPELL_ON_GUARD = 62972,
};
class spell_gen_upper_deck_create_foam_sword : public SpellScriptLoader
{
public:
spell_gen_upper_deck_create_foam_sword() : SpellScriptLoader("spell_gen_upper_deck_create_foam_sword") { }
class spell_gen_upper_deck_create_foam_sword_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_upper_deck_create_foam_sword_SpellScript);
void HandleScript(SpellEffIndex effIndex)
{
if (Player* player = GetHitPlayer())
{
static uint32 const itemId[5] = { ITEM_FOAM_SWORD_GREEN, ITEM_FOAM_SWORD_PINK, ITEM_FOAM_SWORD_BLUE, ITEM_FOAM_SWORD_RED, ITEM_FOAM_SWORD_YELLOW };
// player can only have one of these items
for (uint8 i = 0; i < 5; ++i)
{
if (player->HasItemCount(itemId[i], 1, true))
return;
}
CreateItem(effIndex, itemId[urand(0, 4)]);
}
}
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_gen_upper_deck_create_foam_sword_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_upper_deck_create_foam_sword_SpellScript();
}
};
class spell_gen_bonked : public SpellScriptLoader
{
public:
spell_gen_bonked() : SpellScriptLoader("spell_gen_bonked") { }
class spell_gen_bonked_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_bonked_SpellScript);
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Player* target = GetHitPlayer())
{
Aura const* aura = GetHitAura();
if (!(aura && aura->GetStackAmount() == 3))
return;
target->CastSpell(target, SPELL_FOAM_SWORD_DEFEAT, true);
target->RemoveAurasDueToSpell(SPELL_BONKED);
if (Aura const* aura = target->GetAura(SPELL_ON_GUARD))
{
if (Item* item = target->GetItemByGuid(aura->GetCastItemGUID()))
target->DestroyItemCount(item->GetEntry(), 1, true);
}
}
}
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_gen_bonked_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_bonked_SpellScript();
}
};
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -3148,4 +3238,6 @@ void AddSC_generic_spell_scripts()
new spell_gen_mount("spell_blazing_hippogryph", 0, 0, 0, SPELL_BLAZING_HIPPOGRYPH_150, SPELL_BLAZING_HIPPOGRYPH_280);
new spell_gen_mount("spell_celestial_steed", 0, SPELL_CELESTIAL_STEED_60, SPELL_CELESTIAL_STEED_100, SPELL_CELESTIAL_STEED_150, SPELL_CELESTIAL_STEED_280, SPELL_CELESTIAL_STEED_310);
new spell_gen_mount("spell_x53_touring_rocket", 0, 0, 0, SPELL_X53_TOURING_ROCKET_150, SPELL_X53_TOURING_ROCKET_280, SPELL_X53_TOURING_ROCKET_310);
new spell_gen_upper_deck_create_foam_sword();
new spell_gen_bonked();
}