[12499] Add some safety to some preprocessor defines
[12501] DBScripts Engine: Support buddy search by guid

* Add new `data_flags` flag SCRIPT_FLAG_BUDDY_BY_GUID (0x10)
If this flag is set, the content of `search_distance` is interpreted as db-guid of the requested buddy

* Also switch most error log output to DB-error log output (though this will include false positives)
[12502] DBScripts Engine: Allow pets as buddy

Add new flag SCRIPT_FLAG_BUDDY_IS_PET (0x20) that will search not for a normal npc with buddy-search, but also for pets
[12503] DBScripts Engine: Change behaviour to search for a different npc when using buddy-search

With this an npc buddy will be interpreted as "another npc with entry"

Also toggle command 31 - TERMINATE_SCRIPT to also look only for other npcs of entry
[mr2816] Fix some visibility problems related to broken PhaseMask.
[12504] EventAI: Improve TargetSelection related ErrorLog output

Conflicts:
	src/game/CreatureEventAI.cpp
[12505] Add and implement server-side spell 23770

Conflicts:
	src/game/SQLStorages.cpp
	src/game/SpellEffects.cpp
	src/shared/revision_sql.h
[12507] Implement proc effect of spells 67712, 67758

related to items 47316, 47477.

Signed-off-by: Schmoozerd <schmoozerd@cmangos.net>

Conflicts:
	src/game/SpellMgr.cpp
	src/game/UnitAuraProcHandler.cpp
	src/shared/revision_nr.h
	src/shared/revision_sql.h
[12508] Fix SpellDamage modifier of SPELL_AURA_MOD_DAMAGE_DONE_CREATURE

This aura modifies a flat value, not a percent value.

Related cmangos/cmangos-classic#26

Signed-off-by: Schmoozerd <schmoozerd@cmangos.net>
[12509] Check cast spell 51690

Signed-off-by: Schmoozerd <schmoozerd@cmangos.net>
[12510] Fix take ammo for most ranged spells

Fix spells like Arcane Shot not taking ammo while they should

Close cmangos/mangos-tbc#19

Signed-off-by: cala <calaftp@free.fr>
Signed-off-by: Schmoozerd <schmoozerd@cmangos.net>
[12511] Fix invisible spirit healers & such on death near them

This fixes an issue that occurs if you die close to a spirit healer/guide.
Close cmangos/mangos-tbc#18

Signed-off-by: Schmoozerd <schmoozerd@cmangos.net>
[12512] Implement some spells for Felmyst encounter

Spell entries: 45714, 45717 and 45918. Limit targets of spell 45391
Also add stacking exception for auras 45068 and 45582
[12513] Fixup commit 12511 Thanks to Zakamurite for pointing

Also thanks to him for giving a helping hand in correcting the commit
[12514] Forward original caster GUID to script library

Conflicts:
	src/game/ScriptMgr.h
	src/game/SpellAuras.cpp
[12515] EventAI: Implement ACTION_T_SET_THROW_MASK (46)

This Action can be used to set which AIEvents should be thrown automatically, if you need more flexibility, you can always use the manual ACTION_TH_THROW_AI_EVENT version.

* Also clean some error-log output a bit.
[12516] EventAI: Improve code

* Drop rather pointless bool to check if the number of assigned events is empty
* Before the phase was resetted on death if and only if the npc has Events defined
* DoMeleeAttackIfReady could have been called even though combat state could have changed while processing events

Conflicts:
	src/game/CreatureEventAI.cpp
[mr2817] usable expression from 12517
[12520] Allow spell effect 86 - Activate Object to use the misc value

Close cmangos/issues#220
SD2 update