Skip to content

Commit

Permalink
Core/Spells: Partial revert of 5ddf90c, use checkcast hook for disall…
Browse files Browse the repository at this point in the history
…owing spells to be casted directly

Closes #2108
  • Loading branch information
Shocker committed Jun 24, 2011
1 parent 14cb949 commit 3de4279
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
5 changes: 5 additions & 0 deletions sql/scripts/world_scripts_full.sql
Expand Up @@ -1976,6 +1976,11 @@ INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
( 25281, 'spell_gen_turkey_marker'),
(-55428, 'spell_gen_lifeblood'),
( 65917, 'spell_gen_magic_rooster'),
( 4073, 'spell_gen_allow_cast_from_item_only'),
( 19804, 'spell_gen_allow_cast_from_item_only'),
( 12749, 'spell_gen_allow_cast_from_item_only'),
( 13258, 'spell_gen_allow_cast_from_item_only'),
( 13166, 'spell_gen_allow_cast_from_item_only'),
-- instances
-- Black Temple
( 41475, 'spell_boss_lady_malande_shield'),
Expand Down
7 changes: 7 additions & 0 deletions sql/updates/world/2011_06_24_06_world_spell_script_names.sql
@@ -0,0 +1,7 @@
DELETE FROM `spell_script_names` WHERE `spell_id` IN(4073,19804,12749,13258,13166);
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(4073,'spell_gen_allow_cast_from_item_only'),
(19804,'spell_gen_allow_cast_from_item_only'),
(12749,'spell_gen_allow_cast_from_item_only'),
(13258,'spell_gen_allow_cast_from_item_only'),
(13166,'spell_gen_allow_cast_from_item_only');
3 changes: 0 additions & 3 deletions src/server/game/Spells/Spell.cpp
Expand Up @@ -4652,9 +4652,6 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_spellInfo->AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL && !m_caster->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS))
return SPELL_FAILED_SPELL_UNAVAILABLE;

if (m_castedClientside && m_spellInfo->Attributes & SPELL_ATTR0_HIDDEN_CLIENTSIDE && m_caster->GetTypeId() == TYPEID_PLAYER && !m_CastItem)
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;

// Check global cooldown
if (strict && !m_IsTriggeredSpell && HasGlobalCooldown())
return SPELL_FAILED_NOT_READY;
Expand Down
30 changes: 30 additions & 0 deletions src/server/scripts/Spells/spell_generic.cpp
Expand Up @@ -1125,6 +1125,35 @@ class spell_gen_magic_rooster : public SpellScriptLoader
}
};

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

class spell_gen_allow_cast_from_item_only_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_allow_cast_from_item_only_SpellScript);

SpellCastResult CheckRequirement()
{
if (!GetCastItem())
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;

return SPELL_CAST_OK;
}

void Register()
{
OnCheckCast += SpellCheckCastFn(spell_gen_allow_cast_from_item_only_SpellScript::CheckRequirement);
}
};

SpellScript* GetSpellScript() const
{
return new spell_gen_allow_cast_from_item_only_SpellScript();
}
};

void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
Expand All @@ -1151,4 +1180,5 @@ void AddSC_generic_spell_scripts()
new spell_gen_turkey_marker();
new spell_gen_lifeblood();
new spell_gen_magic_rooster();
new spell_gen_allow_cast_by_item_only();

This comment has been minimized.

Copy link
@StewieGriffin

StewieGriffin Jun 24, 2011

compile error in this line:
"error C2061: syntax error : identifier 'spell_gen_allow_cast_by_item_only'

This comment has been minimized.

Copy link
@Vincent-Michael

Vincent-Michael Jun 24, 2011

Contributor

typo:

  • new spell_gen_allow_cast_by_item_only();
  • new spell_gen_allow_cast_from_item_only();

This comment has been minimized.

Copy link
@StewieGriffin

StewieGriffin Jun 24, 2011

Yes, that fixes it

}

3 comments on commit 3de4279

@luisalvarado
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When compiling on Linux it gives an error. I did a make -j 8 and got this at the end:

[ 36%] Building CXX object src/server/game/CMakeFiles/game.dir/Weather/WeatherMgr.cpp.o
[ 36%] Building CXX object src/server/game/CMakeFiles/game.dir/World/World.cpp.o
Linking CXX static library libgame.a
[ 36%] Built target game
make: *** [all] Error 2
[ 2%] Built target jemalloc
[ 7%] Built target g3dlib
[ 8%] Built target gsoap
[ 8%] Built target revision.h
[ 9%] Built target shared_pch_dephelp
[ 9%] Built target pch_Generate_shared
[ 11%] Built target shared
[ 11%] Built target game_pch_dephelp
[ 12%] Built target pch_Generate_game
[ 32%] Built target game
[ 32%] Built target collision_pch_dephelp
[ 32%] Built target pch_Generate_collision
[ 33%] Built target collision
[ 33%] Built target authserver_pch_dephelp
[ 33%] Built target pch_Generate_authserver
[ 33%] Built target authserver
[ 34%] Built target scripts_pch_dephelp
[ 34%] Built target pch_Generate_scripts
[ 34%] Building CXX object src/server/scripts/CMakeFiles/scripts.dir/Spells/spell_generic.cpp.o
/home/trinity/src/server/scripts/Spells/spell_generic.cpp: In function ‘void AddSC_generic_spell_scripts()’:
/home/trinity/src/server/scripts/Spells/spell_generic.cpp:1183:9: error: expected type-specifier before ‘spell_gen_allow_cast_by_item_only’
/home/trinity/src/server/scripts/Spells/spell_generic.cpp:1183:9: error: expected ‘;’ before ‘spell_gen_allow_cast_by_item_only’
make[2]: *** [src/server/scripts/CMakeFiles/scripts.dir/Spells/spell_generic.cpp.o] Error 1
make[1]: *** [src/server/scripts/CMakeFiles/scripts.dir/all] Error 2
make: *** [all] Error 2

@Shocker
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blah, I did some undo and went too far

@luisalvarado
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry Shocker, you still SHOCK us with your updates ;)

Please sign in to comment.