refactor(Scripts/Item): Make Goblin Weather Machiene script more read… (#15467)
* refactor(Scripts/Item): Make Goblin Weather Machiene script more readable * need to validate spells ofc * initialize the var to make ci happy
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_item_goblin_weather_machine';
|
||||||
|
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_item_goblin_weather_machine_aura';
|
||||||
|
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
|
||||||
|
(46203, 'spell_item_goblin_weather_machine'),
|
||||||
|
(46736, 'spell_item_goblin_weather_machine_aura'),
|
||||||
|
(46738, 'spell_item_goblin_weather_machine_aura'),
|
||||||
|
(46739, 'spell_item_goblin_weather_machine_aura'),
|
||||||
|
(46740, 'spell_item_goblin_weather_machine_aura');
|
||||||
@@ -811,6 +811,44 @@ class spell_item_gnomish_shrink_ray : public SpellScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum GoblinWeatherMachiene
|
||||||
|
{
|
||||||
|
SPELL_PERSONALIZED_WEATHER_RAIN = 46736,
|
||||||
|
SPELL_PERSONALIZED_WEATHER_SNOW = 46738,
|
||||||
|
SPELL_PERSONALIZED_WEATHER_SUN = 46739,
|
||||||
|
SPELL_PERSONALIZED_WEATHER_CLOUDS = 46740
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32 WeatherForcast()
|
||||||
|
{
|
||||||
|
if (!SpellScript::ValidateSpellInfo({
|
||||||
|
SPELL_PERSONALIZED_WEATHER_RAIN,
|
||||||
|
SPELL_PERSONALIZED_WEATHER_SNOW,
|
||||||
|
SPELL_PERSONALIZED_WEATHER_SUN,
|
||||||
|
SPELL_PERSONALIZED_WEATHER_CLOUDS
|
||||||
|
}))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint32 spellId = 0;
|
||||||
|
switch (urand(0, 3))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
spellId = SPELL_PERSONALIZED_WEATHER_RAIN;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
spellId = SPELL_PERSONALIZED_WEATHER_SNOW;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
spellId = SPELL_PERSONALIZED_WEATHER_SUN;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
spellId = SPELL_PERSONALIZED_WEATHER_CLOUDS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return spellId;
|
||||||
|
}
|
||||||
|
|
||||||
class spell_item_goblin_weather_machine : public SpellScript
|
class spell_item_goblin_weather_machine : public SpellScript
|
||||||
{
|
{
|
||||||
PrepareSpellScript(spell_item_goblin_weather_machine);
|
PrepareSpellScript(spell_item_goblin_weather_machine);
|
||||||
@@ -819,18 +857,13 @@ class spell_item_goblin_weather_machine : public SpellScript
|
|||||||
{
|
{
|
||||||
if (Unit* target = GetHitUnit())
|
if (Unit* target = GetHitUnit())
|
||||||
{
|
{
|
||||||
uint32 spellId = 46736;
|
target->CastSpell(target, WeatherForcast(), true);
|
||||||
if (uint8 add = urand(0, 3))
|
|
||||||
spellId += add + 1;
|
|
||||||
|
|
||||||
target->CastSpell(target, spellId, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
if (m_scriptSpellId == 46203)
|
OnEffectHitTarget += SpellEffectFn(spell_item_goblin_weather_machine::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_item_goblin_weather_machine::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -843,17 +876,12 @@ class spell_item_goblin_weather_machine_aura : public AuraScript
|
|||||||
if (roll_chance_i(50))
|
if (roll_chance_i(50))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 spellId = 46736;
|
GetUnitOwner()->CastSpell(GetUnitOwner(), WeatherForcast(), true);
|
||||||
if (uint8 add = urand(0, 3))
|
|
||||||
spellId += add + 1;
|
|
||||||
|
|
||||||
GetUnitOwner()->CastSpell(GetUnitOwner(), spellId, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
if (m_scriptSpellId != 46203)
|
AfterEffectRemove += AuraEffectRemoveFn(spell_item_goblin_weather_machine_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||||
AfterEffectRemove += AuraEffectRemoveFn(spell_item_goblin_weather_machine_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3845,7 +3873,8 @@ void AddSC_item_spell_scripts()
|
|||||||
RegisterSpellScript(spell_item_strong_anti_venom);
|
RegisterSpellScript(spell_item_strong_anti_venom);
|
||||||
RegisterSpellScript(spell_item_anti_venom);
|
RegisterSpellScript(spell_item_anti_venom);
|
||||||
RegisterSpellScript(spell_item_gnomish_shrink_ray);
|
RegisterSpellScript(spell_item_gnomish_shrink_ray);
|
||||||
RegisterSpellAndAuraScriptPair(spell_item_goblin_weather_machine, spell_item_goblin_weather_machine_aura);
|
RegisterSpellScript(spell_item_goblin_weather_machine);
|
||||||
|
RegisterSpellScript(spell_item_goblin_weather_machine_aura);
|
||||||
RegisterSpellScript(spell_item_light_lamp);
|
RegisterSpellScript(spell_item_light_lamp);
|
||||||
RegisterSpellScript(spell_item_fetch_ball);
|
RegisterSpellScript(spell_item_fetch_ball);
|
||||||
RegisterSpellScript(spell_item_oracle_ablutions);
|
RegisterSpellScript(spell_item_oracle_ablutions);
|
||||||
|
|||||||
Reference in New Issue
Block a user