1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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 <http://www.gnu.org/licenses/>.
*/
#include "Player.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
enum eNoblegarden
{
SPELL_NOBLEGARDEN_BUNNY = 61734,
SPELL_WELL_FED = 24870,
};
// 61712 Summon Noblegarden Bunny Controller
class spell_summon_noblegarden_bunny_controller : public SpellScript
{
PrepareSpellScript(spell_summon_noblegarden_bunny_controller);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_NOBLEGARDEN_BUNNY });
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Player* player = GetHitPlayer())
player->CastSpell(player, SPELL_NOBLEGARDEN_BUNNY, true);
}
SpellCastResult CheckCast()
{
if (roll_chance_i(5))
return SPELL_CAST_OK;
return SPELL_FAILED_UNKNOWN;
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_summon_noblegarden_bunny_controller::HandleDummy, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnCheckCast += SpellCheckCastFn(spell_summon_noblegarden_bunny_controller::CheckCast);
}
};
// 61874 - Food (Noblegarden Chocolate, item 44791)
class spell_item_noblegarden_chocolate : public AuraScript
{
PrepareAuraScript(spell_item_noblegarden_chocolate);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_WELL_FED });
}
bool Load() override
{
_buffGiven = false;
return true;
}
void HandlePeriodic(AuraEffect const* /*aurEff*/)
{
if (Unit* caster = GetCaster())
{
uint32 duration = static_cast<uint32>(GetDuration());
if (duration <= 14000 && !_buffGiven)
{
_buffGiven = true;
caster->CastSpell(caster, SPELL_WELL_FED, true);
}
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_item_noblegarden_chocolate::HandlePeriodic, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH);
}
private:
bool _buffGiven;
};
void AddSC_event_noblegarden_scripts()
{
RegisterSpellScript(spell_summon_noblegarden_bunny_controller);
RegisterSpellScript(spell_item_noblegarden_chocolate);
}
|