From 261ad1c5df0cd81d48d1c4d1c330d6089c514990 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 24 Aug 2009 02:38:38 +0400 Subject: [PATCH 01/12] [8412] Update some new and old client supported shift-links to proper format. * List all client and server side supported shift-link types updated in Chat.cpp * Now Henchant anf Hglyph links can be used in commands as spell links. * Hitem and Hquest links changed to client supported form. --- sql/mangos.sql | 6 ++-- sql/updates/8412_01_mangos_mangos_string.sql | 6 ++++ sql/updates/Makefile.am | 2 ++ src/game/Chat.cpp | 32 +++++++++++++++++--- src/game/Level3.cpp | 10 +++--- src/shared/revision_nr.h | 2 +- 6 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 sql/updates/8412_01_mangos_mangos_string.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 49fc0ed79..4be6f94f2 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8399_01_mangos_spell_elixir` bit(1) default NULL + `required_8412_01_mangos_mangos_string` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -2831,8 +2831,8 @@ INSERT INTO `mangos_string` VALUES (509,'%d - sender: %s (guid: %u account: %u ) receiver: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (510,'%d - owner: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (511,'Wrong link type!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(512,'%d - |cffffffff|Hitem:%d:0:0:0:0:0:0:0|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(513,'%d - |cffffffff|Hquest:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(512,'%d - |cffffffff|Hitem:%d:0:0:0:0:0:0:0:0|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(513,'%d - |cffffffff|Hquest:%d:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); (514,'%d - |cffffffff|Hcreature_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (515,'%d - |cffffffff|Hcreature:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (516,'%d - |cffffffff|Hgameobject_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/sql/updates/8412_01_mangos_mangos_string.sql b/sql/updates/8412_01_mangos_mangos_string.sql new file mode 100644 index 000000000..5c99698a5 --- /dev/null +++ b/sql/updates/8412_01_mangos_mangos_string.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8399_01_mangos_spell_elixir required_8412_01_mangos_mangos_string bit; + +DELETE FROM mangos_string WHERE entry IN(512,513); +INSERT INTO mangos_string VALUES +(512,'%d - |cffffffff|Hitem:%d:0:0:0:0:0:0:0:0|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(513,'%d - |cffffffff|Hquest:%d:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index ffb0148bc..7e53ce6f0 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -93,6 +93,7 @@ pkgdata_DATA = \ 8402_01_characters_guild_eventlog.sql \ 8402_02_characters_guild_bank_eventlog.sql \ 8409_01_characters_guild.sql \ + 8412_01_mangos_mangos_string.sql \ README ## Additional files to include when running 'make dist' @@ -166,4 +167,5 @@ EXTRA_DIST = \ 8402_01_characters_guild_eventlog.sql \ 8402_02_characters_guild_bank_eventlog.sql \ 8409_01_characters_guild.sql \ + 8412_01_mangos_mangos_string.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 8f7d8027a..91406678b 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -33,16 +33,21 @@ #include "AccountMgr.h" // Supported shift-links (client generated and server side) +// |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r +// - client, item icon shift click, not used in server currently // |color|Harea:area_id|h[name]|h|r // |color|Hcreature:creature_guid|h[name]|h|r // |color|Hcreature_entry:creature_id|h[name]|h|r +// |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r - client, at shift click in recipes list dialog // |color|Hgameevent:id|h[name]|h|r // |color|Hgameobject:go_guid|h[name]|h|r // |color|Hgameobject_entry:go_id|h[name]|h|r -// |color|Hitem:item_id:perm_ench_id:0:0|h[name]|h|r +// |color|Hglyph:glyph_slot_id:glyph_prop_id|h[%s]|h|r - client, at shift click in glyphs dialog, GlyphSlot.dbc, GlyphProperties.dbc +// |color|Hitem:item_id:perm_ench_id:gem1:gem2:gem3:0:0:0:reporter_level|h[name]|h|r +// - client, item icon shift click // |color|Hitemset:itemset_id|h[name]|h|r // |color|Hplayer:name|h[name]|h|r - client, in some messages, at click copy only name instead link -// |color|Hquest:quest_id|h[name]|h|r +// |color|Hquest:quest_id:quest_level|h[name]|h|r - client, quest list name shift-click // |color|Hskill:skill_id|h[name]|h|r // |color|Hspell:spell_id|h[name]|h|r - client, spellbook spell icon shift-click // |color|Htalent:talent_id,rank|h[name]|h|r - client, talent icon shift-click @@ -1357,9 +1362,11 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid enum SpellLinkType { - SPELL_LINK_SPELL = 0, - SPELL_LINK_TALENT = 1, - SPELL_LINK_TRADE = 2 + SPELL_LINK_SPELL = 0, + SPELL_LINK_TALENT = 1, + SPELL_LINK_TRADE = 2, + SPELL_LINK_ENCHANT = 3, + SPELL_LINK_GLYPH = 4 }; static char const* const spellKeys[] = @@ -1367,11 +1374,15 @@ static char const* const spellKeys[] = "Hspell", // normal spell "Htalent", // talent spell "Htrade", // profession/skill spell + "Henchant", // enchanting recipe spell + "Hglyph", // glyph 0 }; uint32 ChatHandler::extractSpellIdFromLink(char* text) { + // number or [name] Shift-click form |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r + // number or [name] Shift-click form |color|Hglyph:glyph_slot_id:glyph_prop_id|h[%s]|h|r // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r // number or [name] Shift-click form |color|Htalent:talent_id,rank|h[name]|h|r // number or [name] Shift-click form |color|Htrade:spell_id,skill_id,max_value,cur_value|h[name]|h|r @@ -1404,7 +1415,18 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text) return talentEntry->RankID[rank]; } case SPELL_LINK_TRADE: + case SPELL_LINK_ENCHANT: return id; + case SPELL_LINK_GLYPH: + { + uint32 glyph_prop_id = param1_str ? (uint32)atol(param1_str) : 0; + + GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id); + if(!glyphPropEntry) + return 0; + + return glyphPropEntry->SpellId; + } } // unknown type? diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 297c2bb96..8771e2811 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -2935,7 +2935,7 @@ bool ChatHandler::HandleLookupQuestCommand(const char* args) } if (m_session) - PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); + PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),qinfo->GetQuestLevel(),title.c_str(),statusStr); else PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); ++counter; @@ -2969,7 +2969,7 @@ bool ChatHandler::HandleLookupQuestCommand(const char* args) } if (m_session) - PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); + PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),qinfo->GetQuestLevel(),title.c_str(),statusStr); else PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); @@ -4686,7 +4686,7 @@ bool ChatHandler::HandleQuestAdd(const char* args) } // .addquest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r char* cId = extractKeyFromLink((char*)args,"Hquest"); if(!cId) return false; @@ -4740,7 +4740,7 @@ bool ChatHandler::HandleQuestRemove(const char* args) } // .removequest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r char* cId = extractKeyFromLink((char*)args,"Hquest"); if(!cId) return false; @@ -4790,7 +4790,7 @@ bool ChatHandler::HandleQuestComplete(const char* args) } // .quest complete #entry - // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r char* cId = extractKeyFromLink((char*)args,"Hquest"); if(!cId) return false; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 34ff53d61..1be4931cf 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8411" + #define REVISION_NR "8412" #endif // __REVISION_NR_H__ From b91da7846ebff38859a6babb906e18b0bb78026e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 24 Aug 2009 05:08:02 +0400 Subject: [PATCH 02/12] [8413] Fixed lost 0 in comment and swap enum elemys for better fit to 0.12 cases. --- src/game/Chat.cpp | 10 +++++----- src/shared/revision_nr.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 91406678b..c674e4ad8 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -43,7 +43,7 @@ // |color|Hgameobject:go_guid|h[name]|h|r // |color|Hgameobject_entry:go_id|h[name]|h|r // |color|Hglyph:glyph_slot_id:glyph_prop_id|h[%s]|h|r - client, at shift click in glyphs dialog, GlyphSlot.dbc, GlyphProperties.dbc -// |color|Hitem:item_id:perm_ench_id:gem1:gem2:gem3:0:0:0:reporter_level|h[name]|h|r +// |color|Hitem:item_id:perm_ench_id:gem1:gem2:gem3:0:0:0:0:reporter_level|h[name]|h|r // - client, item icon shift click // |color|Hitemset:itemset_id|h[name]|h|r // |color|Hplayer:name|h[name]|h|r - client, in some messages, at click copy only name instead link @@ -1364,8 +1364,8 @@ enum SpellLinkType { SPELL_LINK_SPELL = 0, SPELL_LINK_TALENT = 1, - SPELL_LINK_TRADE = 2, - SPELL_LINK_ENCHANT = 3, + SPELL_LINK_ENCHANT = 2, + SPELL_LINK_TRADE = 3, SPELL_LINK_GLYPH = 4 }; @@ -1373,8 +1373,8 @@ static char const* const spellKeys[] = { "Hspell", // normal spell "Htalent", // talent spell - "Htrade", // profession/skill spell "Henchant", // enchanting recipe spell + "Htrade", // profession/skill spell "Hglyph", // glyph 0 }; @@ -1414,8 +1414,8 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text) return talentEntry->RankID[rank]; } - case SPELL_LINK_TRADE: case SPELL_LINK_ENCHANT: + case SPELL_LINK_TRADE: return id; case SPELL_LINK_GLYPH: { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1be4931cf..6520bedb0 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8412" + #define REVISION_NR "8413" #endif // __REVISION_NR_H__ From 9f015512100612b60ca3bdff4beabc4fdf7b43e8 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 24 Aug 2009 06:39:19 +0400 Subject: [PATCH 03/12] [8414] Re-implement [8406] in more clear and working way. * Rename IsSingleFromSpellSpecificPerCaster to IsSingleFromSpellSpecificPerTargetPerCaster for clear meaning. * Rename IsSingleFromSpellSpecificRanksPerTarget to IsSingleFromSpellSpecificSpellRanksPerTarget for clear meaning. * Add new IsSingleFromSpellSpecificPerTarget for case single spell specific aura allowed to be at target from any caster and use it. Move some spell psecific checks (mostly sellf casted) from IsSingleFromSpellSpecificPerCaster to new function. --- src/game/SpellMgr.cpp | 73 +++++++++++++++++++++++----------------- src/game/SpellMgr.h | 8 +++-- src/game/Unit.cpp | 16 ++++----- src/shared/revision_nr.h | 2 +- 4 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index fc6d8bbf5..85e5389c0 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -277,36 +277,53 @@ SpellSpecific GetSpellSpecific(uint32 spellId) // target not allow have more one spell specific from same caster -bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2) +bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2) { switch(spellSpec1) { - case SPELL_SEAL: case SPELL_BLESSING: case SPELL_AURA: case SPELL_STING: case SPELL_CURSE: + case SPELL_POSITIVE_SHOUT: + case SPELL_JUDGEMENT: + case SPELL_HAND: + return spellSpec1==spellSpec2; + default: + return false; + } +} + +// target not allow have more one ranks from spell from spell specific per target +bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2) +{ + switch(spellSpec1) + { + case SPELL_BLESSING: + case SPELL_AURA: + case SPELL_CURSE: + case SPELL_HAND: + return spellSpec1==spellSpec2; + default: + return false; + } +} + +// target not allow have more one spell specific per target from any caster +bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2) +{ + switch(spellSpec1) + { + case SPELL_SEAL: case SPELL_ASPECT: case SPELL_TRACKER: case SPELL_WARLOCK_ARMOR: case SPELL_MAGE_ARMOR: + case SPELL_ELEMENTAL_SHIELD: case SPELL_MAGE_POLYMORPH: - case SPELL_POSITIVE_SHOUT: - case SPELL_JUDGEMENT: case SPELL_PRESENCE: - case SPELL_HAND: case SPELL_WELL_FED: return spellSpec1==spellSpec2; - case SPELL_FOOD: - return spellSpec2==SPELL_FOOD - || spellSpec2==SPELL_FOOD_AND_DRINK; - case SPELL_DRINK: - return spellSpec2==SPELL_DRINK - || spellSpec2==SPELL_FOOD_AND_DRINK; - case SPELL_FOOD_AND_DRINK: - return spellSpec2==SPELL_FOOD - || spellSpec2==SPELL_DRINK - || spellSpec2==SPELL_FOOD_AND_DRINK; case SPELL_BATTLE_ELIXIR: return spellSpec2==SPELL_BATTLE_ELIXIR || spellSpec2==SPELL_FLASK_ELIXIR; @@ -317,22 +334,16 @@ bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1,SpellSpecific s return spellSpec2==SPELL_BATTLE_ELIXIR || spellSpec2==SPELL_GUARDIAN_ELIXIR || spellSpec2==SPELL_FLASK_ELIXIR; - default: - return false; - } -} - -// target not allow have more one ranks from spell from spell specific per target -bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec, SpellSpecific i_spellId_spec) -{ - switch(spellId_spec) - { - case SPELL_BLESSING: - case SPELL_AURA: - case SPELL_CURSE: - case SPELL_HAND: - case SPELL_ELEMENTAL_SHIELD: - return spellId_spec==i_spellId_spec; + case SPELL_FOOD: + return spellSpec2==SPELL_FOOD + || spellSpec2==SPELL_FOOD_AND_DRINK; + case SPELL_DRINK: + return spellSpec2==SPELL_DRINK + || spellSpec2==SPELL_FOOD_AND_DRINK; + case SPELL_FOOD_AND_DRINK: + return spellSpec2==SPELL_FOOD + || spellSpec2==SPELL_DRINK + || spellSpec2==SPELL_FOOD_AND_DRINK; default: return false; } diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index a5760ea8a..a43e51437 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -180,8 +180,12 @@ inline bool IsLootCraftingSpell(SpellEntry const *spellInfo) } int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); -bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2); -bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec, SpellSpecific i_spellId_spec); + +// order from less to more strict +bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2); +bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2); +bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2); + bool IsPassiveSpell(uint32 spellId); inline bool IsPassiveSpellStackableWithRanks(SpellEntry const* spellProto) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index aa2ee8a85..c66325b6b 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3631,9 +3631,10 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); - // single allowed spell specific from same caster - bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); - if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) + // single allowed spell specific from same caster or from any caster at target + bool is_spellSpecPerTargetPerCaster = IsSingleFromSpellSpecificPerTargetPerCaster(spellId_spec,i_spellId_spec); + bool is_spellSpecPerTarget = IsSingleFromSpellSpecificPerTarget(spellId_spec,i_spellId_spec); + if( is_spellSpecPerTarget || is_spellSpecPerTargetPerCaster && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) { // cannot remove higher rank if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) @@ -3658,9 +3659,8 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) // spell with spell specific that allow single ranks for spell from diff caster // same caster case processed or early or later - bool is_sspt = IsSingleFromSpellSpecificRanksPerTarget(spellId_spec,i_spellId_spec); - if ( is_sspt && Aur->GetCasterGUID() != (*i).second->GetCasterGUID() && - (spellProto->Id == i_spellId || spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId))) + bool is_spellPerTarget = IsSingleFromSpellSpecificSpellRanksPerTarget(spellId_spec,i_spellId_spec); + if ( is_spellPerTarget && Aur->GetCasterGUID() != (*i).second->GetCasterGUID() && spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) { // cannot remove higher rank if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) @@ -3682,8 +3682,8 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) continue; } - // non single per caster spell specific (possible single per target spells at caster) - if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) + // non single (per caster) per target spell specific (possible single spell per target at caster) + if( !is_spellSpecPerTargetPerCaster && !is_spellSpecPerTarget && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) { // Its a parent aura (create this aura in ApplyModifier) if ((*i).second->IsInUse()) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6520bedb0..89bfe25c2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8413" + #define REVISION_NR "8414" #endif // __REVISION_NR_H__ From bee8a0ddce92ac66df303a2d31235f6764bf421a Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 24 Aug 2009 13:54:13 +0400 Subject: [PATCH 04/12] [8415] Implement --enable-builtin-ace option for explicit select builtin/system ACE. * --enable-builtin-ace (default) set use builting in mangos sources ACE version build and use * --disable-builtin-ace set use installed in system ACE version (if any) or error if no system version installed. This let easy use system version of ACE if it prefered by some reasons (for example 5.5.2 ACE package at 6.x FreeBSD) * This also fix proper detection Stack_Trace.h existance in both cases. More proper header existance check base at patch suggested by Plaes. Thanks to Splinter for testing. --- configure.ac | 32 +++++++++++++++++++++++++------- src/shared/revision_nr.h | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 4fc5e6d68..c9f635b78 100644 --- a/configure.ac +++ b/configure.ac @@ -201,16 +201,34 @@ AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS([atexit ftime gethostbyaddr gethostbyname gethostname gettimeofday memmove memset pow realpath select socket sqrt strchr strdup strerror strstr]) -PKG_CHECK_MODULES(ACE, [ACE >= 5.5.2], [need_to_build_ace=no], [need_to_build_ace=yes]) -if test X$need_to_build_ace = Xyes ; then + +# Check for use buildtin ACE sources +AC_ARG_ENABLE(builtin_ace, AC_HELP_STRING([--enable-builtin-ace], [turn on/off using builtin ACE sources])) + +enable_builtin_ace_support=yes + +if test "x$enable_builtin_ace" = "xno"; then + PKG_CHECK_MODULES(ACE, [ACE >= 5.5.2], [need_builtin_ace=no], [need_builtin_ace=yes]) + if test X$need_builtin_ace = Xyes ; then + AC_MSG_ERROR([You need to install ACE package or use built-in ACE sources]) + fi + enable_builtin_ace_support=no +fi + +if test X$enable_builtin_ace_support = Xno; then + + # old ace versions might not have ace/Stack_Trace.h... + AC_LANG_PUSH([C++]) + AC_CHECK_HEADERS([ace/Stack_Trace.h]) + AC_LANG_POP +else + # ...but we certainly have it in our included version + AC_DEFINE(HAVE_ACE_STACK_TRACE_H) ACE_INCLUDES="-I\$(top_srcdir)/dep/ACE_wrappers -I\$(top_builddir)/dep/ACE_wrappers" ACE_LIBS="\$(top_builddir)/dep/ACE_wrappers/ace/libACE.la" fi -AM_CONDITIONAL([MANGOS_BUILD_ACE], [test X$need_to_build_ace = Xyes]) - -# old ace versions not have ace/Stack_Trace.h -AC_CHECK_HEADERS([ace/Stack_Trace.h]) +AM_CONDITIONAL([MANGOS_BUILD_ACE], [test X$enable_builtin_ace_support = Xyes]) ## Unify all additional includes/libs in one variable. # TODO this looks kinda ugly, but when we add m4 folder I will make it look very pritey ( by Derex ). @@ -261,7 +279,7 @@ AC_CONFIG_FILES([ ]) ## Configure ACE, if needed -if test X$need_to_build_ace = Xyes; then +if test X$enable_builtin_ace_support = Xyes; then AC_CONFIG_SUBDIRS([dep/ACE_wrappers]) fi diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 89bfe25c2..acce70f84 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8414" + #define REVISION_NR "8415" #endif // __REVISION_NR_H__ From 208c84556e0de28193f07994a98e7dde78335402 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 25 Aug 2009 08:19:58 +0400 Subject: [PATCH 05/12] [8416] Fixed problem with double cast form passives at loading. * Drop learning form passives at form psell learning, and cast it explictly from code in all cases. * Drop cast form passives at learning. * Note: talents that have dependent form time passives still work in original way: learned and casted at learn if need. * Drop hack for spell 24907 casting at form apply: it casted fines as result normal triggered effect in related form spell. Original patch provided by nos4r2zod. --- sql/mangos.sql | 21 +--------------- .../8416_01_mangos_spell_learn_spell.sql | 21 ++++++++++++++++ sql/updates/Makefile.am | 2 ++ src/game/Player.cpp | 21 +++------------- src/game/SpellAuras.cpp | 24 ++++++++++--------- src/shared/revision_nr.h | 2 +- 6 files changed, 41 insertions(+), 50 deletions(-) create mode 100644 sql/updates/8416_01_mangos_spell_learn_spell.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 4be6f94f2..d67c83cfb 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8412_01_mangos_mangos_string` bit(1) default NULL + `required_8416_01_mangos_spell_learn_spell` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -17045,39 +17045,20 @@ CREATE TABLE `spell_learn_spell` ( LOCK TABLES `spell_learn_spell` WRITE; /*!40000 ALTER TABLE `spell_learn_spell` DISABLE KEYS */; INSERT INTO `spell_learn_spell` VALUES -(71,7376,0), -(768,3025,0), -(783,5419,0), -(1066,5421,0), -(2457,21156,0), -(2458,7381,0), -(5487,1178,0), -(5487,21178,0), (5784,33388,1), -(9634,9635,0), -(9634,21178,0), (13819,33388,1), (17002,24867,0), (23161,33391,1), (23214,33391,1), -(24858,24905,0), (24866,24864,0), (33872,47179,0), (33873,47180,0), -(33891,5420,0), -(33891,34123,0), -(33943,33948,0), (33943,34090,1), -(33943,34764,0), (34767,33391,1), (34769,33388,1), -(40123,40121,0), -(40123,40122,0), (53428,53341,1), (53428,53343,1), (58984,21009,1); - - /*!40000 ALTER TABLE `spell_learn_spell` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/8416_01_mangos_spell_learn_spell.sql b/sql/updates/8416_01_mangos_spell_learn_spell.sql new file mode 100644 index 000000000..86066e05a --- /dev/null +++ b/sql/updates/8416_01_mangos_spell_learn_spell.sql @@ -0,0 +1,21 @@ +ALTER TABLE db_version CHANGE COLUMN required_8412_01_mangos_mangos_string required_8416_01_mangos_spell_learn_spell bit; + +/* All form passives */ +DELETE FROM spell_learn_spell WHERE SpellID in ( +1178, /* Bear Form (Passive) */ +3025, /* Cat Form (Passive) */ +5419, /* Travel Form (Passive) */ +5420, /* Tree of Life _passive_ */ +5421, /* Aquatic Form (Passive) */ +7376, /* Defensive Stance Passive */ +7381, /* Berserker Stance Passive */ +9635, /* Dire Bear Form (Passive) */ +21156, /* Battle Stance Passive */ +21178, /* Bear Form (Passive2) */ +24905, /* Moonkin Form (Passive) */ +34123, /* Tree of Life _pasive_ */ +33948, /* Flight Form (Passive) */ +34764, /* Flight Form (Passive) */ +40121, /* Swift Flight Form (Passive) */ +40122 /* Swift Flight Form (Passive) */ +); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 7e53ce6f0..d6e7b108f 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -94,6 +94,7 @@ pkgdata_DATA = \ 8402_02_characters_guild_bank_eventlog.sql \ 8409_01_characters_guild.sql \ 8412_01_mangos_mangos_string.sql \ + 8416_01_mangos_spell_learn_spell.sql \ README ## Additional files to include when running 'make dist' @@ -168,4 +169,5 @@ EXTRA_DIST = \ 8402_02_characters_guild_bank_eventlog.sql \ 8409_01_characters_guild.sql \ 8412_01_mangos_mangos_string.sql \ + 8416_01_mangos_spell_learn_spell.sql \ README diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0866f1709..51bb78d16 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3116,24 +3116,9 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const { - bool need_cast = false; - - switch(spellInfo->Id) - { - // some spells not have stance data expected cast at form change or present - case 5420: need_cast = (m_form == FORM_TREE); break; - case 5419: need_cast = (m_form == FORM_TRAVEL); break; - case 7376: need_cast = (m_form == FORM_DEFENSIVESTANCE); break; - case 7381: need_cast = (m_form == FORM_BERSERKERSTANCE); break; - case 21156: need_cast = (m_form == FORM_BATTLESTANCE); break; - case 21178: need_cast = (m_form == FORM_BEAR || m_form == FORM_DIREBEAR); break; - case 33948: need_cast = (m_form == FORM_FLIGHT); break; - case 34764: need_cast = (m_form == FORM_FLIGHT); break; - case 40121: need_cast = (m_form == FORM_FLIGHT_EPIC); break; - case 40122: need_cast = (m_form == FORM_FLIGHT_EPIC); break; - // another spells have proper stance data - default: need_cast = !spellInfo->Stances || m_form != 0 && (spellInfo->Stances & (1<<(m_form-1))); break; - } + // note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell + // talent dependent passives activated at form apply have proper stance data + bool need_cast = !spellInfo->Stances || m_form != 0 && (spellInfo->Stances & (1<<(m_form-1))); //Check CasterAuraStates return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState))); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 09c9d9f42..f7936c4ec 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -5474,8 +5474,6 @@ void Aura::HandleShapeshiftBoosts(bool apply) break; case FORM_MOONKIN: spellId1 = 24905; - // aura from effect trigger spell - spellId2 = 24907; MasterShaperSpellId = 48421; break; case FORM_FLIGHT: @@ -5483,15 +5481,15 @@ void Aura::HandleShapeshiftBoosts(bool apply) spellId2 = 34764; break; case FORM_FLIGHT_EPIC: - spellId1 = 40122; + spellId1 = 40122; spellId2 = 40121; break; case FORM_METAMORPHOSIS: - spellId1 = 54817; + spellId1 = 54817; spellId2 = 54879; break; case FORM_SPIRITOFREDEMPTION: - spellId1 = 27792; + spellId1 = 27792; spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation. break; case FORM_SHADOW: @@ -5506,14 +5504,15 @@ void Aura::HandleShapeshiftBoosts(bool apply) case FORM_STEALTH: case FORM_CREATURECAT: case FORM_CREATUREBEAR: - spellId1 = 0; break; } if(apply) { - if (spellId1) m_target->CastSpell(m_target, spellId1, true, NULL, this ); - if (spellId2) m_target->CastSpell(m_target, spellId2, true, NULL, this); + if (spellId1) + m_target->CastSpell(m_target, spellId1, true, NULL, this ); + if (spellId2) + m_target->CastSpell(m_target, spellId2, true, NULL, this); if (m_target->GetTypeId() == TYPEID_PLAYER) { @@ -5604,9 +5603,12 @@ void Aura::HandleShapeshiftBoosts(bool apply) } else { - m_target->RemoveAurasDueToSpell(spellId1); - m_target->RemoveAurasDueToSpell(spellId2); - m_target->RemoveAurasDueToSpell(MasterShaperSpellId); + if(spellId1) + m_target->RemoveAurasDueToSpell(spellId1); + if(spellId2) + m_target->RemoveAurasDueToSpell(spellId2); + if(MasterShaperSpellId) + m_target->RemoveAurasDueToSpell(MasterShaperSpellId); Unit::AuraMap& tAuras = m_target->GetAuras(); for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index acce70f84..a0dc0915a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8415" + #define REVISION_NR "8416" #endif // __REVISION_NR_H__ From c2f8a0ff7d9ff030ec71c544de6d2b991e2d383e Mon Sep 17 00:00:00 2001 From: OPenaz Date: Tue, 25 Aug 2009 13:57:00 +0400 Subject: [PATCH 06/12] [8417] Allow work some guardian summon spells. Signed-off-by: VladimirMangos --- src/game/SharedDefines.h | 3 ++- src/game/SpellEffects.cpp | 1 + src/shared/revision_nr.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index d8066ed55..2539b19e4 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -2407,7 +2407,8 @@ enum SummonType SUMMON_TYPE_UNKNOWN2 = 427, SUMMON_TYPE_POSESSED2 = 428, SUMMON_TYPE_INFERNO = 711, - SUMMON_TYPE_GUARDIAN2 = 1161, + SUMMON_TYPE_GUARDIAN2 = 713, + SUMMON_TYPE_GUARDIAN3 = 1161, SUMMON_TYPE_ELEMENTAL = 1561, SUMMON_TYPE_FORCE_OF_NATURE = 1562 }; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index fd987c8d8..49c7c4493 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3269,6 +3269,7 @@ void Spell::EffectSummonType(uint32 i) case SUMMON_TYPE_POSESSED2: case SUMMON_TYPE_FORCE_OF_NATURE: case SUMMON_TYPE_GUARDIAN2: + case SUMMON_TYPE_GUARDIAN3: // Jewelery statue case (totem like) if(m_spellInfo->SpellIconID == 2056) EffectSummonTotem(i); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a0dc0915a..eb0d2096b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8416" + #define REVISION_NR "8417" #endif // __REVISION_NR_H__ From 0c78bfba331d1ae8d11e77f2392cbd7115fc4c4d Mon Sep 17 00:00:00 2001 From: Astellar Date: Tue, 25 Aug 2009 14:51:22 +0400 Subject: [PATCH 07/12] [8418] Implement work talent 47193. Signed-off-by: VladimirMangos --- src/game/SpellAuras.cpp | 6 ++++++ src/game/SpellEffects.cpp | 45 +++++++++++++++++++++++++++++++++++++-- src/shared/revision_nr.h | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index f7936c4ec..ba2721410 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -4887,11 +4887,17 @@ void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings) case 44055: // Tremendous Fortitude (Battlemaster's Alacrity) case 50322: // Survival Instincts + case 54443: // Demonic Empowerment (Voidwalker) { if(Real) { if(apply) { + // Demonic Empowerment (Voidwalker) - special case, store percent in data + // recalculate to full amount at apply for proper remove + if (GetId() == 54443) + m_modifier.m_amount = m_target->GetMaxHealth() * m_modifier.m_amount / 100; + m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); m_target->ModifyHealth(m_modifier.m_amount); } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 49c7c4493..d5d82c579 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4918,11 +4918,26 @@ void Spell::EffectScriptEffect(uint32 effIndex) unitTarget->HandleEmoteCommand(EMOTE_STATE_DANCE); return; } + // Demonic Empowerment (succubus Vanish effect) + case 54436: + { + if(!unitTarget) + return; + + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED); + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_STUN); + return; + } // Escape artist case 20589: { - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); + if(!unitTarget) + return; + + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); return; } // Mirren's Drinking Hat @@ -4948,6 +4963,8 @@ void Spell::EffectScriptEffect(uint32 effIndex) // Improved Sprint case 30918: { + if(!unitTarget) + return; // Removes snares and roots. uint32 mechanic_mask = (1<GetAuras(); @@ -5116,6 +5133,8 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 47871: case 47878: { + if(!unitTarget) + return; uint32 itemtype; uint32 rank = 0; Unit::AuraList const& mDummyAuras = unitTarget->GetAurasByType(SPELL_AURA_DUMMY); @@ -5168,6 +5187,26 @@ void Spell::EffectScriptEffect(uint32 effIndex) DoCreateItem( effIndex, itemtype ); return; } + // Demonic Empowerment + case 47193: + { + if(!unitTarget) + return; + uint32 entry = unitTarget->GetEntry(); + uint32 spellID; + switch(entry) + { + case 416: spellID = 54444; break; //imp + case 417: spellID = 54509; break; //fellhunter + case 1860: spellID = 54443; break; //void + case 1863: spellID = 54435; break; //succubus + case 17252: spellID = 54508; break; //fellguard + default: + return; + } + unitTarget->CastSpell(unitTarget,spellID,true); + return; + } // Everlasting Affliction case 47422: { @@ -5222,6 +5261,8 @@ void Spell::EffectScriptEffect(uint32 effIndex) // Chimera Shot case 53209: { + if(!unitTarget) + return; uint32 spellId = 0; int32 basePoint = 0; Unit* target = unitTarget; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index eb0d2096b..a8db5e5cb 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8417" + #define REVISION_NR "8418" #endif // __REVISION_NR_H__ From 344c03fc03f22b699fbe0ec365d08294df5d1b30 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 25 Aug 2009 15:32:35 +0400 Subject: [PATCH 08/12] [8419] Allow updating pet stats at loading more early (before InitStatsForLevel). --- src/game/Pet.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 487267322..3581c456f 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -224,6 +224,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool if(owner->IsPvP()) SetPvP(true); + SetCanModifyStats(true); InitStatsForLevel(petlevel); InitTalentForLevel(); // set original talents points before spell loading @@ -263,7 +264,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool delete result; //load spells/cooldowns/auras - SetCanModifyStats(true); _LoadAuras(timediff); //init AB diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a8db5e5cb..e3c88796c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8418" + #define REVISION_NR "8419" #endif // __REVISION_NR_H__ From 8231eed7bf96cbec20f1ade581d935543bab6052 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 26 Aug 2009 02:31:09 +0400 Subject: [PATCH 09/12] [8420] Update and continue fill mangos_spell_check.sql. Small related code cleanups. --- sql/mangos_spell_check.sql | 28 ++- src/game/SpellEffects.cpp | 453 +++++++++++++++++++------------------ src/shared/revision_nr.h | 2 +- 3 files changed, 253 insertions(+), 230 deletions(-) diff --git a/sql/mangos_spell_check.sql b/sql/mangos_spell_check.sql index a1a93cb43..1585270f7 100644 --- a/sql/mangos_spell_check.sql +++ b/sql/mangos_spell_check.sql @@ -16,7 +16,7 @@ /* re-adding before command use. So need just adding new line to file. */ /* Current table fill progress state: */ -/* SpellEffect.cpp from start until end of Spell::EffectPowerBurn */ +/* SpellEffect.cpp from start until end of Spell::EffectEnchantItemPrismatic */ DROP TABLE IF EXISTS spell_check; CREATE TABLE `spell_check` ( @@ -41,6 +41,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (1454, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'), (1455, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'), (1456, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'), +(9512, -1, -1, -1, -1, -1, -1, 30, -1,-1,'Restore Energy', 'Spell::EffectEnergize'), (4073, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Mechanical Dragonling', 'Spell::EffectDummy'), (5938, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Shiv', 'Spell::EffectDummy'), (5940, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Shiv', 'Spell::EffectDummy'), @@ -58,7 +59,6 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (8220, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Flip Out', 'Spell::EffectDummy'), (8221, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Yaaarrrr', 'Spell::EffectDummy'), (8222, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Yaaarrrr', 'Spell::EffectDummy'), -(8326, -1, -1, -1, -1, -1, -1, 6, -1,-1,'Ghost', 'Spell::EffectApplyAura'), (8593, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Symbol of life', 'Spell::EffectDummy'), (10399,11,0x0000000000400000,0x00000000, -1, -1, -1, 3, -1,-1,'Rockbiter Weapon', 'Spell::EffectDummy'), (11687, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'), @@ -93,13 +93,13 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (18790,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'), (18791,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'), (18792,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'), +(19658,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Devour Magic Effect', 'Spell::EffectDispel'), (19804,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Arcanite Dragonling', 'Spell::EffectDummy'), (20187,10, -1, -1, -1, -1, -1, 3, -1,-1,'Judgement of Righteousness', 'Spell::EffectDummy'), (20253, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Intercept', 'Spell::EffectSchoolDMG'), (20473,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'), (20577, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Cannibalize', 'Spell::EffectDummy'), (20578,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cannibalize', 'Spell::EffectDummy'), -(20584,-1, -1, -1, -1, -1, -1, 6, -1,-1,'Ghost', 'Spell::EffectApplyAura'), (20647,-1, -1, -1, -1, -1, -1, 2, -1, 0,'Execute', 'Spell::EffectDummy'), (20929,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'), (20930,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'), @@ -128,7 +128,15 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (23885,-1, -1, -1, -1, -1, -1, 6, 42, 0,'Bloodthirst', 'Spell::EffectDummy'), (23989, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Readiness', 'Spell::EffectDummy'), (24340, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'), +(24532,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Burst of Energy', 'Spell::EffectEnergize'), +(24571,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Blood Fury', 'Spell::EffectEnergize'), (24575,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Brittle Armor', 'Spell::EffectTriggerSpell'), +(24950,-1, -1, -1, -1, -1, -1, 24, -1,-1,'Create Warsong Mark of Honor (Loser)','Spell::DoCreateItem'), +(24951,-1, -1, -1, -1, -1, -1, 24, -1,-1,'Create Warsong Mark of Honor (WInner)','Spell::DoCreateItem'), +(24952,-1, -1, -1, -1, -1, -1, 24, -1,-1,'Arathi Basin Mark of Honor (Loser)', 'Spell::DoCreateItem'), +(24953,-1, -1, -1, -1, -1, -1, 24, -1,-1,'Arathi Basin Mark of Honor (Winner)','Spell::DoCreateItem'), +(24954,-1, -1, -1, -1, -1, -1, 24, -1,-1,'Alterac Valley Mark of Honor (Loser)','Spell::DoCreateItem'), +(24955,-1, -1, -1, -1, -1, -1, 24, -1,-1,'Alterac Valley Mark of Honor (Winner)','Spell::DoCreateItem'), (25599, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Thundercrash', 'Spell::EffectSchoolDMG'), (25858,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Reindeer', 'Spell::EffectDummy'), (25859,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Reindeer', 'Spell::EffectDummy'), @@ -174,6 +182,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (31790,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Righteous Defense', 'Spell::EffectTriggerSpell'), (31803,-1, -1, -1, -1, -1, -1, 6, 3,-1,'Holy Vengeance', 'Spell::EffectSchoolDMG'), (31818,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Life Tap', 'Spell::EffectDummy'), +(31930,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Judgements of the Wise', 'Spell::EffectEnergize'), (32409,-1, -1, -1, -1, -1, -1, 6, 3,-1,'Shadow Word: Death', 'Spell::EffectSchoolDMG'), (32553,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Life Tap', 'Spell::EffectDummy'), (32813,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Squirrel Form', 'Spell::EffectDummy'), @@ -231,7 +240,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (39610,11, -1, -1, -1, -1, -1, 3, -1,-1,'Mana Tide Totem effect', 'Spell::EffectDummy'), (40810, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Saber Lash', 'Spell::EffectSchoolDMG'), (41276, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'), -(41637,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Prayer of Mending', 'Spell::EffectApplyAura'), +(41637,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Prayer of Mending', 'Spell::cast'), (42384, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Brutal Swipe', 'Spell::EffectSchoolDMG'), (43267, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Saber Lash', 'Spell::EffectSchoolDMG'), (43268, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Saber Lash', 'Spell::EffectSchoolDMG'), @@ -246,8 +255,11 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (44997, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Converting Sentry', 'Spell::EffectDummy'), (45009,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Converted Sentry Credit', 'Spell::EffectDummy'), (45030, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Impale Emissary', 'Spell::EffectDummy'), +(45062,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Holy Energy', 'Spell::EffectHeal'), +(45064,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Vessel of the Naaru', 'Spell::EffectHeal'), (45088,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Emissary of Hate Credit', 'Spell::EffectDummy'), (45150, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'), +(45470,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Intercept', 'Spell::EffectDummy'), (64422, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'), (64688, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'), (45182,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cheat Death', 'Spell::EffectDummy'), @@ -298,6 +310,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (53341, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rune of Cinderglacier', 'Spell::EffectDummy'), (53343, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rune of Razorice', 'Spell::EffectDummy'), (54586,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Runeforging Credit', 'Spell::EffectDummy'), +(54824,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Swiftmend', 'Spell::EffectHeal'), (54861,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Nitro Boosts', 'Spell::EffectDummy'), (55004, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Nitro Boosts', 'Spell::EffectDummy'), (55441,11, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Mana Tide', 'Spell::EffectDummy'), @@ -314,6 +327,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (61290, 5,0x0001000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'), (61291,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'), (61491, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Intercept', 'Spell::EffectSchoolDMG'), +(63375,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Improved Stormstrike', 'Spell::EffectEnergize'), /* sorted by spell names */ /*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */ @@ -328,6 +342,8 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas ( 0, 9,0x0008000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Counterattack', 'Spell::EffectSchoolDMG'), ( 0, 8,0x0000000000010000,0x00000000, -1, -1, -1, -1, 3,-1,'Deadly poison', 'Spell::EffectSchoolDMG'), ( 0,15,0x0000000000002000,0x00000000, -1, -1, -1, 3, -1,-1,'Death Coil', 'Spell::EffectDummy'), +( 0,15,0x0000000000000010,0x00000000, -1, -1, -1, 3, -1,-1,'Death Strike', 'Spell::EffectDummy'), +( 0, 5, -1, -1, -1, -1, 12, 38, -1,-1,'Devour Magic', 'Spell::EffectDispel'), ( 0, 8,0x0000000800000000,0x00000000, -1, -1, -1, 2, -1,-1,'Envenom', 'Spell::EffectSchoolDMG'), ( 0, 8,0x0000000000020000,0x00000000, -1, -1, -1, 2, -1,-1,'Eviscerate', 'Spell::EffectSchoolDMG'), (0, 4,0x0000000020000000,0x00000000, -1, -1, -1, 3, -1,-1,'Execute', 'Spell::EffectDummy'), @@ -356,8 +372,10 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas ( 0, 7,0x0000044000000000,0x00000000, -1, -1, -1, -1, -1,-1,'Mangle (Cat) and Mangle (Bear)', 'Unit::HandleDummyAuraProc'), ( 0, 9,0x0000000000000002,0x00000000, -1, 342, -1, 2, -1,-1,'Mongoose Bite', 'Spell::EffectSchoolDMG'), (0, 6,0x0080000000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Penance', 'Spell::EffectDummy'), -( 0, 6,0x0000002000000000,0x00000000, -1, -1, -1, 6, -1,-1,'Prayer of Mending', 'Spell::EffectApplyAura'), +( 0, 6,0x0000002000000000,0x00000000, -1, -1, -1, 6, -1,-1,'Prayer of Mending', 'Spell::cast'), ( 0, 8,0x0000024000000860,0x00000000, -1, -1, -1, -1, -1,-1,'Preparation (affected spells)', 'Spell::EffectDummy'), +( 0, 7,0x0000000000000040,0x00000000, -1, -1, -1, -1, 8,-1,'Regrowth', 'Spell::EffectHeal'), +( 0, 7,0x0000000000000010,0x00000000, -1, -1, -1, -1, 8,-1,'Rejuvenation', 'Spell::EffectHeal'), ( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 2, -1,-1,'Rake', 'Spell::EffectSchoolDMG'), /* used in */ ( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 80, -1, 2,'Rake', 'Spell::EffectSchoolDMG'), /* exactly selected */ ( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, -1, 3,-1,'Rake', 'Aura::HandlePeriodicDamage'), /* used in */ diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d5d82c579..b323738f3 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -670,7 +670,7 @@ void Spell::EffectSchoolDMG(uint32 effect_idx) void Spell::EffectDummy(uint32 i) { - if(!unitTarget && !gameObjTarget && !itemTarget) + if (!unitTarget && !gameObjTarget && !itemTarget) return; // selection by spell family @@ -682,7 +682,7 @@ void Spell::EffectDummy(uint32 i) { case 8063: // Deviate Fish { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -699,7 +699,7 @@ void Spell::EffectDummy(uint32 i) } case 8213: // Savory Deviate Delight { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -716,7 +716,7 @@ void Spell::EffectDummy(uint32 i) case 8593: // Symbol of life (restore creature to life) case 31225: // Shimmering Vessel (restore creature to life) { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) return; ((Creature*)unitTarget)->setDeathState(JUST_ALIVED); return; @@ -725,7 +725,7 @@ void Spell::EffectDummy(uint32 i) case 12850: // (now good common check for this spells) case 12868: { - if(!unitTarget) + if (!unitTarget) return; float damage; @@ -748,7 +748,7 @@ void Spell::EffectDummy(uint32 i) // get remaining damage of old Deep Wound aura Aura* deepWound = unitTarget->GetAura(12721, 0); - if(deepWound) + if (deepWound) { int32 remainingTicks = deepWound->GetAuraDuration() / deepWound->GetModifier()->periodictime; damage += remainingTicks * deepWound->GetModifier()->m_amount; @@ -761,16 +761,16 @@ void Spell::EffectDummy(uint32 i) } case 13120: // net-o-matic { - if(!unitTarget) + if (!unitTarget) return; uint32 spell_id = 0; uint32 roll = urand(0, 99); - if(roll < 2) // 2% for 30 sec self root (off-like chance unknown) + if (roll < 2) // 2% for 30 sec self root (off-like chance unknown) spell_id = 16566; - else if(roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) + else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) spell_id = 13119; else // normal root spell_id = 13099; @@ -781,7 +781,7 @@ void Spell::EffectDummy(uint32 i) case 13567: // Dummy Trigger { // can be used for different aura triggering, so select by aura - if(!m_triggeredByAuraSpell || !unitTarget) + if (!m_triggeredByAuraSpell || !unitTarget) return; switch(m_triggeredByAuraSpell->Id) @@ -798,7 +798,7 @@ void Spell::EffectDummy(uint32 i) case 15998: // Capture Worg Pup case 29435: // Capture Female Kaliri Hatchling { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) return; Creature* creatureTarget = (Creature*)unitTarget; @@ -808,7 +808,7 @@ void Spell::EffectDummy(uint32 i) } case 16589: // Noggenfogger Elixir { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -824,10 +824,10 @@ void Spell::EffectDummy(uint32 i) } case 17251: // Spirit Healer Res { - if(!unitTarget || !m_originalCaster) + if (!unitTarget || !m_originalCaster) return; - if(m_originalCaster->GetTypeId() == TYPEID_PLAYER) + if (m_originalCaster->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); data << uint64(unitTarget->GetGUID()); @@ -837,7 +837,7 @@ void Spell::EffectDummy(uint32 i) } case 17271: // Test Fetid Skull { - if(!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) + if (!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) return; uint32 spell_id = roll_chance_i(50) @@ -853,11 +853,11 @@ void Spell::EffectDummy(uint32 i) return; case 23019: // Crystal Prison Dummy DND { - if(!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->isPet()) + if (!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->isPet()) return; Creature* creatureTarget = (Creature*)unitTarget; - if(creatureTarget->isPet()) + if (creatureTarget->isPet()) return; GameObject* pGameObj = new GameObject; @@ -865,7 +865,7 @@ void Spell::EffectDummy(uint32 i) Map *map = creatureTarget->GetMap(); // create before death for get proper coordinates - if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(), + if (!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(), creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), creatureTarget->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY) ) { @@ -890,34 +890,38 @@ void Spell::EffectDummy(uint32 i) return; } case 23074: // Arcanite Dragonling - if (!m_CastItem) return; + if (!m_CastItem) + return; m_caster->CastSpell(m_caster, 19804, true, m_CastItem); return; case 23075: // Mithril Mechanical Dragonling - if (!m_CastItem) return; + if (!m_CastItem) + return; m_caster->CastSpell(m_caster, 12749, true, m_CastItem); return; case 23076: // Mechanical Dragonling - if (!m_CastItem) return; + if (!m_CastItem) + return; m_caster->CastSpell(m_caster, 4073, true, m_CastItem); return; case 23133: // Gnomish Battle Chicken - if (!m_CastItem) return; + if (!m_CastItem) + return; m_caster->CastSpell(m_caster, 13166, true, m_CastItem); return; case 23448: // Transporter Arrival - Ultrasafe Transporter: Gadgetzan - backfires { int32 r = irand(0, 119); - if ( r < 20 ) // Transporter Malfunction - 1/6 polymorph + if (r < 20) // Transporter Malfunction - 1/6 polymorph m_caster->CastSpell(m_caster, 23444, true); - else if ( r < 100 ) // Evil Twin - 4/6 evil twin + else if (r < 100) // Evil Twin - 4/6 evil twin m_caster->CastSpell(m_caster, 23445, true); else // Transporter Malfunction - 1/6 miss the target m_caster->CastSpell(m_caster, 36902, true); return; } case 23453: // Gnomish Transporter - Ultrasafe Transporter: Gadgetzan - if ( roll_chance_i(50) ) // Gadgetzan Transporter - success + if (roll_chance_i(50)) // Gadgetzan Transporter - success m_caster->CastSpell(m_caster, 23441, true); else // Gadgetzan Transporter Failure - failure m_caster->CastSpell(m_caster, 23446, true); @@ -970,7 +974,7 @@ void Spell::EffectDummy(uint32 i) } case 29200: // Purify Helboar Meat { - if( m_caster->GetTypeId() != TYPEID_PLAYER ) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = roll_chance_i(50) @@ -985,22 +989,24 @@ void Spell::EffectDummy(uint32 i) m_caster->CastSpell(unitTarget,32835,true); return; case 30458: // Nigh Invulnerability - if (!m_CastItem) return; - if(roll_chance_i(86)) // Nigh-Invulnerability - success + if (!m_CastItem) + return; + if (roll_chance_i(86)) // Nigh-Invulnerability - success m_caster->CastSpell(m_caster, 30456, true, m_CastItem); else // Complete Vulnerability - backfire in 14% casts m_caster->CastSpell(m_caster, 30457, true, m_CastItem); return; case 30507: // Poultryizer - if (!m_CastItem) return; - if(roll_chance_i(80)) // Poultryized! - success + if(!m_CastItem) + return; + if (roll_chance_i(80)) // Poultryized! - success m_caster->CastSpell(unitTarget, 30501, true, m_CastItem); else // Poultryized! - backfire 20% m_caster->CastSpell(unitTarget, 30504, true, m_CastItem); return; case 33060: // Make a Wish { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId()!=TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -1032,7 +1038,7 @@ void Spell::EffectDummy(uint32 i) } case 37674: // Chaos Blast { - if(!unitTarget) + if (!unitTarget) return; int32 basepoints0 = 100; @@ -1085,7 +1091,7 @@ void Spell::EffectDummy(uint32 i) */ case 44875: // Complete Raptor Capture { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) return; Creature* creatureTarget = (Creature*)unitTarget; @@ -1098,7 +1104,7 @@ void Spell::EffectDummy(uint32 i) } case 34665: //Administer Antidote { - if(!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER ) + if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER ) return; // Spell has scriptable target but for sure. if (unitTarget->GetTypeId() != TYPEID_UNIT) @@ -1134,21 +1140,22 @@ void Spell::EffectDummy(uint32 i) return; } case 55004: // Nitro Boosts - if(!m_CastItem) return; - if(roll_chance_i(95)) // Nitro Boosts - success + if (!m_CastItem) + return; + if (roll_chance_i(95)) // Nitro Boosts - success m_caster->CastSpell(m_caster, 54861, true, m_CastItem); else // Knocked Up - backfire 5% m_caster->CastSpell(m_caster, 46014, true, m_CastItem); return; case 50243: // Teach Language { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; // spell has a 1/3 chance to trigger one of the below - if(roll_chance_i(66)) + if (roll_chance_i(66)) return; - if(((Player*)m_caster)->GetTeam() == ALLIANCE) + if (((Player*)m_caster)->GetTeam() == ALLIANCE) { // 1000001 - gnomish binary m_caster->CastSpell(m_caster, 50242, true); @@ -1163,10 +1170,10 @@ void Spell::EffectDummy(uint32 i) } case 51582: //Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - if(BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) + if (BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) bg->EventPlayerDroppedFlag((Player*)m_caster); m_caster->CastSpell(m_caster, 30452, true, NULL); @@ -1174,7 +1181,7 @@ void Spell::EffectDummy(uint32 i) } case 51592: // Pickup Primordial Hatchling { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) return; Creature* creatureTarget = (Creature*)unitTarget; @@ -1218,7 +1225,7 @@ void Spell::EffectDummy(uint32 i) return; // implemented in EffectScript[0] case 59640: // Underbelly Elixir { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -1263,7 +1270,7 @@ void Spell::EffectDummy(uint32 i) { case 11958: // Cold Snap { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId()!=TYPEID_PLAYER) return; // immediately finishes the cooldown on Frost spells @@ -1272,9 +1279,9 @@ void Spell::EffectDummy(uint32 i) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); - if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && + if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) && - spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 ) + spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0) { ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first, true); } @@ -1285,7 +1292,7 @@ void Spell::EffectDummy(uint32 i) } case 32826: // Polymorph Cast Visual { - if ( unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT ) + if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) { //Polymorph Cast Visual Rank 1 const uint32 spell_list[6] = { @@ -1304,14 +1311,14 @@ void Spell::EffectDummy(uint32 i) break; case SPELLFAMILY_WARRIOR: // Charge - if((m_spellInfo->SpellFamilyFlags & UI64LIT(0x1)) && m_spellInfo->SpellVisual[0] == 867) + if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x1)) && m_spellInfo->SpellVisual[0] == 867) { int32 chargeBasePoints0 = damage; m_caster->CastCustomSpell(m_caster, 34846, &chargeBasePoints0, NULL, NULL, true); return; } // Execute - if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x20000000)) + if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x20000000)) { if(!unitTarget) return; @@ -1328,7 +1335,7 @@ void Spell::EffectDummy(uint32 i) return; } // Slam - if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000200000)) + if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000200000)) { if(!unitTarget) return; @@ -1337,7 +1344,7 @@ void Spell::EffectDummy(uint32 i) return; } // Concussion Blow - if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) + if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) { m_damage+= uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); return; @@ -1347,7 +1354,7 @@ void Spell::EffectDummy(uint32 i) // Warrior's Wrath case 21977: { - if(!unitTarget) + if (!unitTarget) return; m_caster->CastSpell(unitTarget, 21887, true);// spell mod return; @@ -1389,7 +1396,7 @@ void Spell::EffectDummy(uint32 i) } // Think its not need (also need remove Life Tap from SpellDamageBonus or add new value) // damage = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(damage > 0 ? damage : 0), SPELL_DIRECT_DAMAGE); - if(unitTarget && (int32(unitTarget->GetHealth()) > damage)) + if (unitTarget && (int32(unitTarget->GetHealth()) > damage)) { // Shouldn't Appear in Combat Log unitTarget->ModifyHealth(-damage); @@ -1412,7 +1419,7 @@ void Spell::EffectDummy(uint32 i) if((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 1982) manaFeedVal+= (*itr)->GetModifier()->m_amount; } - if(manaFeedVal > 0) + if (manaFeedVal > 0) { manaFeedVal = manaFeedVal * mana / 100; m_caster->CastCustomSpell(m_caster, 32553, &manaFeedVal, NULL, NULL, true, NULL); @@ -1462,7 +1469,7 @@ void Spell::EffectDummy(uint32 i) } //Any effect which causes you to lose control of your character will supress the starfall effect. - if(m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED)) + if (m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED)) return; switch(m_spellInfo->Id) @@ -1482,31 +1489,31 @@ void Spell::EffectDummy(uint32 i) { case 5938: // Shiv { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player *pCaster = ((Player*)m_caster); Item *item = pCaster->GetWeaponForAttack(OFF_ATTACK); - if(!item) + if (!item) return; // all poison enchantments is temporary uint32 enchant_id = item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT); - if(!enchant_id) + if (!enchant_id) return; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) + if (!pEnchant) return; for (int s=0;s<3;s++) { - if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) + if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) continue; SpellEntry const* combatEntry = sSpellStore.LookupEntry(pEnchant->spellid[s]); - if(!combatEntry || combatEntry->Dispel != DISPEL_POISON) + if (!combatEntry || combatEntry->Dispel != DISPEL_POISON) continue; m_caster->CastSpell(unitTarget, combatEntry, true, item); @@ -1517,7 +1524,7 @@ void Spell::EffectDummy(uint32 i) } case 14185: // Preparation { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId()!=TYPEID_PLAYER) return; //immediately finishes the cooldown on certain Rogue abilities @@ -1542,9 +1549,9 @@ void Spell::EffectDummy(uint32 i) break; case SPELLFAMILY_HUNTER: // Steady Shot - if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x100000000)) + if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x100000000)) { - if( !unitTarget || !unitTarget->isAlive()) + if (!unitTarget || !unitTarget->isAlive()) return; bool found = false; @@ -1553,14 +1560,14 @@ void Spell::EffectDummy(uint32 i) Unit::AuraList const& decSpeedList = unitTarget->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED); for(Unit::AuraList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) { - if((*iter)->GetSpellProto()->SpellIconID==15 && (*iter)->GetSpellProto()->Dispel==0) + if ((*iter)->GetSpellProto()->SpellIconID==15 && (*iter)->GetSpellProto()->Dispel==0) { found = true; break; } } - if(found) + if (found) m_damage+= damage; return; } @@ -1569,7 +1576,7 @@ void Spell::EffectDummy(uint32 i) { case 23989: // Readiness talent { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId()!=TYPEID_PLAYER) return; //immediately finishes the cooldown for hunter abilities @@ -1603,7 +1610,7 @@ void Spell::EffectDummy(uint32 i) { case 156: // Holy Shock { - if(!unitTarget) + if (!unitTarget) return; int hurt = 0; @@ -1623,7 +1630,7 @@ void Spell::EffectDummy(uint32 i) return; } - if(m_caster->IsFriendlyTo(unitTarget)) + if (m_caster->IsFriendlyTo(unitTarget)) m_caster->CastSpell(unitTarget, heal, true, 0); else m_caster->CastSpell(unitTarget, hurt, true, 0); @@ -1632,15 +1639,15 @@ void Spell::EffectDummy(uint32 i) } case 561: // Judgement of command { - if(!unitTarget) + if (!unitTarget) return; uint32 spell_id = m_currentBasePoints[i]+1; SpellEntry const* spell_proto = sSpellStore.LookupEntry(spell_id); - if(!spell_proto) + if (!spell_proto) return; - if( !unitTarget->hasUnitState(UNIT_STAT_STUNNED) && m_caster->GetTypeId()==TYPEID_PLAYER) + if (!unitTarget->hasUnitState(UNIT_STAT_STUNNED) && m_caster->GetTypeId()==TYPEID_PLAYER) { // decreased damage (/2) for non-stunned target. SpellModifier *mod = new SpellModifier; @@ -1680,7 +1687,7 @@ void Spell::EffectDummy(uint32 i) // non-standard cast requirement check if (!unitTarget || unitTarget->getAttackers().empty()) { - if(m_caster->GetTypeId()==TYPEID_PLAYER) + if (m_caster->GetTypeId()==TYPEID_PLAYER) ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true); SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); return; @@ -1699,7 +1706,7 @@ void Spell::EffectDummy(uint32 i) uint32 count=0; for(Unit::AttackerSet::const_iterator aItr = attackers.begin(); aItr != attackers.end() && count < 3; ++aItr) { - if(!roll_chance_f(chance)) + if (!roll_chance_f(chance)) continue; ++count; AddUnitTarget((*aItr), 1); @@ -1710,7 +1717,7 @@ void Spell::EffectDummy(uint32 i) } case 37877: // Blessing of Faith { - if(!unitTarget) + if (!unitTarget) return; uint32 spell_id = 0; @@ -1746,22 +1753,22 @@ void Spell::EffectDummy(uint32 i) return; } - SpellEntry const *spellInfo = sSpellStore.LookupEntry( spell_id ); + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - if(!spellInfo) + if (!spellInfo) { sLog.outError("WORLD: unknown spell id %i", spell_id); return; } - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; for(int j = BASE_ATTACK; j <= OFF_ATTACK; ++j) { - if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(j))) + if (Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(j))) { - if(item->IsFitToSpellRequirements(m_spellInfo)) + if (item->IsFitToSpellRequirements(m_spellInfo)) { Spell *spell = new Spell(m_caster, spellInfo, true); @@ -1779,31 +1786,31 @@ void Spell::EffectDummy(uint32 i) return; } // Cleansing Totem - if((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) && m_spellInfo->SpellIconID==1673) + if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) && m_spellInfo->SpellIconID==1673) { m_caster->CastSpell(unitTarget, 52025, true); return; } // Healing Stream Totem - if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000002000)) + if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000002000)) { m_caster->CastCustomSpell(unitTarget, 52042, &damage, 0, 0, true, 0, 0, m_originalCasterGUID); return; } // Mana Spring Totem - if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000004000)) + if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000004000)) { - if(unitTarget->getPowerType()!=POWER_MANA) + if (unitTarget->getPowerType()!=POWER_MANA) return; m_caster->CastCustomSpell(unitTarget, 52032, &damage, 0, 0, true, 0, 0, m_originalCasterGUID); return; } - if(m_spellInfo->Id == 39610) // Mana Tide Totem effect + if (m_spellInfo->Id == 39610) // Mana Tide Totem effect { - if(!unitTarget || unitTarget->getPowerType() != POWER_MANA) + if (!unitTarget || unitTarget->getPowerType() != POWER_MANA) return; // Glyph of Mana Tide - if(Unit *owner = m_caster->GetOwner()) + if (Unit *owner = m_caster->GetOwner()) if (Aura *dummy = owner->GetDummyAura(55441)) damage+=dummy->GetModifier()->m_amount; // Regenerate 6% of Total Mana Every 3 secs @@ -1823,7 +1830,7 @@ void Spell::EffectDummy(uint32 i) Unit::AuraList const& auraDummy = m_caster->GetAurasByType(SPELL_AURA_DUMMY); for(Unit::AuraList::const_iterator itr = auraDummy.begin(); itr != auraDummy.end(); ++itr) { - if( (*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_SHAMAN && + if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_SHAMAN && ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000200000)) && (*itr)->GetCastItemGUID() == item->GetGUID()) { @@ -1839,9 +1846,9 @@ void Spell::EffectDummy(uint32 i) // Death Coil if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x002000)) { - if(m_caster->IsFriendlyTo(unitTarget)) + if (m_caster->IsFriendlyTo(unitTarget)) { - if(unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) + if (unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) return; int32 bp = damage * 1.5f; @@ -1867,13 +1874,13 @@ void Spell::EffectDummy(uint32 i) Unit::AuraMap const& auras = unitTarget->GetAuras(); for(Unit::AuraMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) { - if(itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE && + if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE && itr->second->GetCasterGUID() == m_caster->GetGUID() && IsSpellLastAuraEffect(itr->second->GetSpellProto(), itr->second->GetEffIndex())) { ++count; // max. 15% - if(count == 3) + if (count == 3) break; } } @@ -1886,7 +1893,7 @@ void Spell::EffectDummy(uint32 i) } // pet auras - if(PetAura const* petSpell = spellmgr.GetPetAura(m_spellInfo->Id, i)) + if (PetAura const* petSpell = spellmgr.GetPetAura(m_spellInfo->Id, i)) { m_caster->AddPetAura(petSpell); return; @@ -1894,11 +1901,11 @@ void Spell::EffectDummy(uint32 i) // Script based implementation. Must be used only for not good for implementation in core spell effects // So called only for not proccessed cases - if(gameObjTarget) + if (gameObjTarget) Script->EffectDummyGameObj(m_caster, m_spellInfo->Id, i, gameObjTarget); - else if(unitTarget && unitTarget->GetTypeId()==TYPEID_UNIT) + else if (unitTarget && unitTarget->GetTypeId()==TYPEID_UNIT) Script->EffectDummyCreature(m_caster, m_spellInfo->Id, i, (Creature*)unitTarget); - else if(itemTarget) + else if (itemTarget) Script->EffectDummyItem(m_caster, m_spellInfo->Id, i, itemTarget); } @@ -2476,22 +2483,22 @@ void Spell::EffectSendEvent(uint32 EffectIndex) void Spell::EffectPowerBurn(uint32 i) { - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + if (m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) return; Powers powertype = Powers(m_spellInfo->EffectMiscValue[i]); - if(!unitTarget) + if (!unitTarget) return; - if(!unitTarget->isAlive()) + if (!unitTarget->isAlive()) return; - if(unitTarget->getPowerType()!=powertype) + if (unitTarget->getPowerType()!=powertype) return; - if(damage < 0) + if (damage < 0) return; // burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn) - if(m_spellInfo->ManaCostPercentage) + if (m_spellInfo->ManaCostPercentage) { uint32 maxdamage = m_caster->GetMaxPower(powertype) * damage * 2 / 100; damage = unitTarget->GetMaxPower(powertype) * damage / 100; @@ -2502,7 +2509,7 @@ void Spell::EffectPowerBurn(uint32 i) // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) uint32 power = damage; - if ( powertype == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER ) + if (powertype == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER) power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power); int32 new_damage = (curPower < power) ? curPower : power; @@ -2510,7 +2517,7 @@ void Spell::EffectPowerBurn(uint32 i) unitTarget->ModifyPower(powertype, -new_damage); float multiplier = m_spellInfo->EffectMultipleValue[i]; - if(Player *modOwner = m_caster->GetSpellModOwner()) + if (Player *modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); new_damage = int32(new_damage * multiplier); @@ -2519,7 +2526,7 @@ void Spell::EffectPowerBurn(uint32 i) void Spell::EffectHeal( uint32 /*i*/ ) { - if( unitTarget && unitTarget->isAlive() && damage >= 0) + if (unitTarget && unitTarget->isAlive() && damage >= 0) { // Try to get original caster Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; @@ -2537,7 +2544,7 @@ void Spell::EffectHeal( uint32 /*i*/ ) int damageAmount = 0; Unit::AuraList const& mDummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); for(Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) - if((*i)->GetId() == 45062) + if ((*i)->GetId() == 45062) damageAmount+=(*i)->GetModifier()->m_amount; if (damageAmount) m_caster->RemoveAurasDueToSpell(45062); @@ -2556,12 +2563,12 @@ void Spell::EffectHeal( uint32 /*i*/ ) // Regrowth or Rejuvenation 0x40 | 0x10 ((*i)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000050))) { - if(!targetAura || (*i)->GetAuraDuration() < targetAura->GetAuraDuration()) + if (!targetAura || (*i)->GetAuraDuration() < targetAura->GetAuraDuration()) targetAura = *i; } } - if(!targetAura) + if (!targetAura) { sLog.outError("Target (GUID: %u TypeId: %u) has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUIDLow(), unitTarget->GetTypeId()); return; @@ -2578,7 +2585,7 @@ void Spell::EffectHeal( uint32 /*i*/ ) int32 tickcount = GetSpellDuration(targetAura->GetSpellProto()) / targetAura->GetSpellProto()->EffectAmplitude[idx]; // Glyph of Swiftmend - if(!caster->HasAura(54824)) + if (!caster->HasAura(54824)) unitTarget->RemoveAurasDueToSpell(targetAura->GetId()); addhealth += tickheal * tickcount; @@ -2592,7 +2599,7 @@ void Spell::EffectHeal( uint32 /*i*/ ) void Spell::EffectHealPct( uint32 /*i*/ ) { - if( unitTarget && unitTarget->isAlive() && damage >= 0) + if (unitTarget && unitTarget->isAlive() && damage >= 0) { // Try to get original caster Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; @@ -2602,7 +2609,7 @@ void Spell::EffectHealPct( uint32 /*i*/ ) return; uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; - if(Player* modOwner = m_caster->GetSpellModOwner()) + if (Player* modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, addhealth, this); int32 gain = caster->DealHeal(unitTarget, addhealth, m_spellInfo); @@ -2613,7 +2620,7 @@ void Spell::EffectHealPct( uint32 /*i*/ ) void Spell::EffectHealMechanical( uint32 /*i*/ ) { // Mechanic creature type should be correctly checked by targetCreatureType field - if( unitTarget && unitTarget->isAlive() && damage >= 0) + if (unitTarget && unitTarget->isAlive() && damage >= 0) { // Try to get original caster Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; @@ -2629,34 +2636,32 @@ void Spell::EffectHealMechanical( uint32 /*i*/ ) void Spell::EffectHealthLeech(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(!unitTarget->isAlive()) + if (!unitTarget->isAlive()) return; - if(damage < 0) + if (damage < 0) return; sLog.outDebug("HealthLeech :%i", damage); float multiplier = m_spellInfo->EffectMultipleValue[i]; - if(Player *modOwner = m_caster->GetSpellModOwner()) + if (Player *modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); int32 new_damage = int32(damage*multiplier); uint32 curHealth = unitTarget->GetHealth(); new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage ); - if(curHealth < new_damage) + if (curHealth < new_damage) new_damage = curHealth; - if(m_caster->isAlive()) + if (m_caster->isAlive()) { new_damage = m_caster->SpellHealingBonus(m_caster, m_spellInfo, new_damage, HEAL); m_caster->DealHeal(m_caster, uint32(new_damage), m_spellInfo); } -// m_healthLeech+=tmpvalue; -// m_damage+=new_damage; } void Spell::DoCreateItem(uint32 i, uint32 itemtype) @@ -2796,7 +2801,7 @@ void Spell::EffectCreateItem(uint32 i) void Spell::EffectCreateItem2(uint32 i) { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)m_caster; @@ -2805,9 +2810,9 @@ void Spell::EffectCreateItem2(uint32 i) DoCreateItem(i, item_id); // special case: fake item replaced by generate using spell_loot_template - if(IsLootCraftingSpell(m_spellInfo)) + if (IsLootCraftingSpell(m_spellInfo)) { - if(!player->HasItemCount(item_id, 1)) + if (!player->HasItemCount(item_id, 1)) return; // remove reagent @@ -2821,7 +2826,7 @@ void Spell::EffectCreateItem2(uint32 i) void Spell::EffectCreateRandomItem(uint32 i) { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)m_caster; @@ -2833,12 +2838,12 @@ void Spell::EffectPersistentAA(uint32 i) { float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - if(Player* modOwner = m_caster->GetSpellModOwner()) + if (Player* modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius); int32 duration = GetSpellDuration(m_spellInfo); DynamicObject* dynObj = new DynamicObject; - if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + if (!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) { delete dynObj; return; @@ -2942,18 +2947,18 @@ void Spell::EffectEnergize(uint32 i) void Spell::EffectEnergisePct(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(!unitTarget->isAlive()) + if (!unitTarget->isAlive()) return; - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + if (m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) return; Powers power = Powers(m_spellInfo->EffectMiscValue[i]); uint32 maxPower = unitTarget->GetMaxPower(power); - if(maxPower == 0) + if (maxPower == 0) return; uint32 gain = damage * maxPower / 100; @@ -2987,7 +2992,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) case GAMEOBJECT_TYPE_SPELL_FOCUS: // triggering linked GO - if(uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); return; @@ -3002,7 +3007,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) // cast goober spell if (gameObjTarget->GetGOInfo()->goober.questId) ///Quest require to be active for GO using - if(player->GetQuestStatus(gameObjTarget->GetGOInfo()->goober.questId) != QUEST_STATUS_INCOMPLETE) + if (player->GetQuestStatus(gameObjTarget->GetGOInfo()->goober.questId) != QUEST_STATUS_INCOMPLETE) return; gameObjTarget->AddUniqueUse(player); @@ -3015,7 +3020,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) player->CastedCreatureOrGO(gameObjTarget->GetEntry(), gameObjTarget->GetGUID(), 0); // triggering linked GO - if(uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId) + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId) gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); return; @@ -3029,7 +3034,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) } // triggering linked GO - if(uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); // Don't return, let loots been taken @@ -3044,7 +3049,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) void Spell::EffectOpenLock(uint32 effIndex) { - if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) { sLog.outDebug( "WORLD: Open Lock - No Player Caster!"); return; @@ -3056,19 +3061,19 @@ void Spell::EffectOpenLock(uint32 effIndex) uint64 guid = 0; // Get lockId - if(gameObjTarget) + if (gameObjTarget) { GameObjectInfo const* goInfo = gameObjTarget->GetGOInfo(); // Arathi Basin banner opening ! - if( goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune || - goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK ) + if (goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune || + goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK) { //CanUseBattleGroundObject() already called in CheckCast() // in battleground check - if(BattleGround *bg = player->GetBattleGround()) + if (BattleGround *bg = player->GetBattleGround()) { // check if it's correct bg - if(bg && bg->GetTypeID() == BATTLEGROUND_AB) + if (bg && bg->GetTypeID() == BATTLEGROUND_AB) bg->EventPlayerClickedOnFlag(player, gameObjTarget); return; } @@ -3077,9 +3082,9 @@ void Spell::EffectOpenLock(uint32 effIndex) { //CanUseBattleGroundObject() already called in CheckCast() // in battleground check - if(BattleGround *bg = player->GetBattleGround()) + if (BattleGround *bg = player->GetBattleGround()) { - if(bg->GetTypeID() == BATTLEGROUND_EY) + if (bg->GetTypeID() == BATTLEGROUND_EY) bg->EventPlayerClickedOnFlag(player, gameObjTarget); return; } @@ -3087,7 +3092,7 @@ void Spell::EffectOpenLock(uint32 effIndex) lockId = goInfo->GetLockId(); guid = gameObjTarget->GetGUID(); } - else if(itemTarget) + else if (itemTarget) { lockId = itemTarget->GetProto()->LockID; guid = itemTarget->GetGUID(); @@ -3103,7 +3108,7 @@ void Spell::EffectOpenLock(uint32 effIndex) int32 skillValue; SpellCastResult res = CanOpenLock(effIndex, lockId, skillId, reqSkillValue, skillValue); - if(res != SPELL_CAST_OK) + if (res != SPELL_CAST_OK) { SendCastResult(res); return; @@ -3112,19 +3117,19 @@ void Spell::EffectOpenLock(uint32 effIndex) SendLoot(guid, LOOT_SKINNING); // not allow use skill grow at item base open - if(!m_CastItem && skillId != SKILL_NONE) + if (!m_CastItem && skillId != SKILL_NONE) { // update skill if really known - if(uint32 pureSkillValue = player->GetPureSkillValue(skillId)) + if (uint32 pureSkillValue = player->GetPureSkillValue(skillId)) { - if(gameObjTarget) + if (gameObjTarget) { // Allow one skill-up until respawned - if ( !gameObjTarget->IsInSkillupList( player->GetGUIDLow() ) && - player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue) ) - gameObjTarget->AddToSkillupList( player->GetGUIDLow() ); + if (!gameObjTarget->IsInSkillupList(player->GetGUIDLow()) && + player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) + gameObjTarget->AddToSkillupList(player->GetGUIDLow()); } - else if(itemTarget) + else if (itemTarget) { // Do one skill-up player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue); @@ -3135,51 +3140,51 @@ void Spell::EffectOpenLock(uint32 effIndex) void Spell::EffectSummonChangeItem(uint32 i) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player *player = (Player*)m_caster; // applied only to using item - if(!m_CastItem) + if (!m_CastItem) return; // ... only to item in own inventory/bank/equip_slot - if(m_CastItem->GetOwnerGUID()!=player->GetGUID()) + if (m_CastItem->GetOwnerGUID()!=player->GetGUID()) return; uint32 newitemid = m_spellInfo->EffectItemType[i]; - if(!newitemid) + if (!newitemid) return; uint16 pos = m_CastItem->GetPos(); Item *pNewItem = Item::CreateItem( newitemid, 1, player); - if( !pNewItem ) + if (!pNewItem) return; for(uint8 j= PERM_ENCHANTMENT_SLOT; j<=TEMP_ENCHANTMENT_SLOT; ++j) { - if(m_CastItem->GetEnchantmentId(EnchantmentSlot(j))) + if (m_CastItem->GetEnchantmentId(EnchantmentSlot(j))) pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j))); } - if(m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) + if (m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) { double loosePercent = 1 - m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) / double(m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)); player->DurabilityLoss(pNewItem, loosePercent); } - if( player->IsInventoryPos( pos ) ) + if (player->IsInventoryPos(pos)) { ItemPosCountVec dest; uint8 msg = player->CanStoreItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); - if( msg == EQUIP_ERR_OK ) + if (msg == EQUIP_ERR_OK) { player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true); // prevent crash at access and unexpected charges counting with item update queue corrupt - if(m_CastItem==m_targets.getItemTarget()) + if (m_CastItem==m_targets.getItemTarget()) m_targets.setItemTarget(NULL); m_CastItem = NULL; @@ -3188,16 +3193,16 @@ void Spell::EffectSummonChangeItem(uint32 i) return; } } - else if( player->IsBankPos ( pos ) ) + else if (player->IsBankPos (pos)) { ItemPosCountVec dest; uint8 msg = player->CanBankItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); - if( msg == EQUIP_ERR_OK ) + if (msg == EQUIP_ERR_OK) { player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true); // prevent crash at access and unexpected charges counting with item update queue corrupt - if(m_CastItem==m_targets.getItemTarget()) + if (m_CastItem==m_targets.getItemTarget()) m_targets.setItemTarget(NULL); m_CastItem = NULL; @@ -3206,16 +3211,16 @@ void Spell::EffectSummonChangeItem(uint32 i) return; } } - else if( player->IsEquipmentPos ( pos ) ) + else if (player->IsEquipmentPos (pos)) { uint16 dest; uint8 msg = player->CanEquipItem( m_CastItem->GetSlot(), dest, pNewItem, true ); - if( msg == EQUIP_ERR_OK ) + if (msg == EQUIP_ERR_OK) { player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true); // prevent crash at access and unexpected charges counting with item update queue corrupt - if(m_CastItem==m_targets.getItemTarget()) + if (m_CastItem==m_targets.getItemTarget()) m_targets.setItemTarget(NULL); m_CastItem = NULL; @@ -3237,12 +3242,12 @@ void Spell::EffectProficiency(uint32 /*i*/) Player *p_target = (Player*)unitTarget; uint32 subClassMask = m_spellInfo->EquippedItemSubClassMask; - if(m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && !(p_target->GetWeaponProficiency() & subClassMask)) + if (m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && !(p_target->GetWeaponProficiency() & subClassMask)) { p_target->AddWeaponProficiency(subClassMask); p_target->SendProficiency(ITEM_CLASS_WEAPON, p_target->GetWeaponProficiency()); } - if(m_spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && !(p_target->GetArmorProficiency() & subClassMask)) + if (m_spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && !(p_target->GetArmorProficiency() & subClassMask)) { p_target->AddArmorProficiency(subClassMask); p_target->SendProficiency(ITEM_CLASS_ARMOR, p_target->GetArmorProficiency()); @@ -3251,9 +3256,9 @@ void Spell::EffectProficiency(uint32 /*i*/) void Spell::EffectApplyAreaAura(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(!unitTarget->isAlive()) + if (!unitTarget->isAlive()) return; AreaAura* Aur = new AreaAura(m_spellInfo, i, &m_currentBasePoints[i], unitTarget, m_caster, m_CastItem); @@ -3313,22 +3318,22 @@ void Spell::EffectSummonType(uint32 i) void Spell::EffectSummon(uint32 i) { - if(m_caster->GetPetGUID()) + if (m_caster->GetPetGUID()) return; - if(!unitTarget) + if (!unitTarget) return; uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; - if(!pet_entry) + if (!pet_entry) return; uint32 level = m_caster->getLevel(); Pet* spawnCreature = new Pet(SUMMON_PET); - if(m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster,pet_entry)) + if (m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster,pet_entry)) { // Summon in dest location float x, y, z; - if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { x = m_targets.m_destX; y = m_targets.m_destY; @@ -3338,7 +3343,7 @@ void Spell::EffectSummon(uint32 i) // set timer for unsummon int32 duration = GetSpellDuration(m_spellInfo); - if(duration > 0) + if (duration > 0) spawnCreature->SetDuration(duration); return; @@ -3346,7 +3351,7 @@ void Spell::EffectSummon(uint32 i) Map *map = m_caster->GetMap(); uint32 pet_number = objmgr.GeneratePetNumber(); - if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(), + if (!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(), m_spellInfo->EffectMiscValue[i], pet_number)) { sLog.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo->EffectMiscValue[i]); @@ -3356,7 +3361,7 @@ void Spell::EffectSummon(uint32 i) // Summon in dest location float x, y, z; - if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { x = m_targets.m_destX; y = m_targets.m_destY; @@ -3367,7 +3372,7 @@ void Spell::EffectSummon(uint32 i) spawnCreature->Relocate(x, y, z, -m_caster->GetOrientation()); - if(!spawnCreature->IsPositionValid()) + if (!spawnCreature->IsPositionValid()) { sLog.outError("Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); @@ -3377,7 +3382,7 @@ void Spell::EffectSummon(uint32 i) // set timer for unsummon int32 duration = GetSpellDuration(m_spellInfo); - if(duration > 0) + if (duration > 0) spawnCreature->SetDuration(duration); spawnCreature->SetOwnerGUID(m_caster->GetGUID()); @@ -3411,7 +3416,7 @@ void Spell::EffectSummon(uint32 i) m_caster->SetPet(spawnCreature); - if(m_caster->GetTypeId() == TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) { spawnCreature->GetCharmInfo()->SetReactState( REACT_DEFENSIVE ); spawnCreature->SavePetToDB(PET_SAVE_AS_CURRENT); @@ -3421,12 +3426,12 @@ void Spell::EffectSummon(uint32 i) void Spell::EffectLearnSpell(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) { - if(m_caster->GetTypeId() == TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) EffectLearnPetSpell(i); return; @@ -3442,7 +3447,7 @@ void Spell::EffectLearnSpell(uint32 i) void Spell::EffectDispel(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; // Fill possible dispell list @@ -3467,7 +3472,7 @@ void Spell::EffectDispel(uint32 i) // do not remove positive auras if friendly target // negative auras if non-friendly target - if(positive == unitTarget->IsFriendlyTo(m_caster)) + if (positive == unitTarget->IsFriendlyTo(m_caster)) continue; } // Add aura to dispel list @@ -3599,15 +3604,15 @@ void Spell::EffectDistract(uint32 /*i*/) void Spell::EffectPickPocket(uint32 /*i*/) { - if( m_caster->GetTypeId() != TYPEID_PLAYER ) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; // victim must be creature and attackable - if( !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget) ) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget)) return; // victim have to be alive and humanoid or undead - if( unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) + if (unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) { int32 chance = 10 + int32(m_caster->getLevel()) - int32(unitTarget->getLevel()); @@ -3648,19 +3653,19 @@ void Spell::EffectAddFarsight(uint32 i) void Spell::EffectSummonWild(uint32 i) { uint32 creature_entry = m_spellInfo->EffectMiscValue[i]; - if(!creature_entry) + if (!creature_entry) return; uint32 level = m_caster->getLevel(); // level of creature summoned using engineering item based at engineering skill level - if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) + if (m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) { ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) + if (proto && proto->RequiredSkill == SKILL_ENGINERING) { uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) + if (skill202) { level = skill202/5; } @@ -3708,7 +3713,7 @@ void Spell::EffectSummonWild(uint32 i) void Spell::EffectSummonGuardian(uint32 i) { uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; - if(!pet_entry) + if (!pet_entry) return; // set timer for unsummon @@ -3717,7 +3722,7 @@ void Spell::EffectSummonGuardian(uint32 i) // Search old Guardian only for players (if casted spell not have duration or cooldown) // FIXME: some guardians have control spell applied and controlled by player and anyway player can't summon in this time // so this code hack in fact - if( m_caster->GetTypeId() == TYPEID_PLAYER && (duration <= 0 || GetSpellRecoveryTime(m_spellInfo) == 0) ) + if (m_caster->GetTypeId() == TYPEID_PLAYER && (duration <= 0 || GetSpellRecoveryTime(m_spellInfo) == 0)) if(m_caster->FindGuardianWithEntry(pet_entry)) return; // find old guardian, ignore summon @@ -3725,13 +3730,13 @@ void Spell::EffectSummonGuardian(uint32 i) uint32 level = m_caster->getLevel(); // level of pet summoned using engineering item based at engineering skill level - if(m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem) + if (m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem) { ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) + if (proto && proto->RequiredSkill == SKILL_ENGINERING) { uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) + if (skill202) { level = skill202 / 5; } @@ -3753,7 +3758,7 @@ void Spell::EffectSummonGuardian(uint32 i) Map *map = m_caster->GetMap(); uint32 pet_number = objmgr.GeneratePetNumber(); - if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(), + if (!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(), m_spellInfo->EffectMiscValue[i], pet_number)) { sLog.outError("no such creature entry %u", m_spellInfo->EffectMiscValue[i]); @@ -3782,7 +3787,7 @@ void Spell::EffectSummonGuardian(uint32 i) spawnCreature->Relocate(px, py, pz, m_caster->GetOrientation()); - if(!spawnCreature->IsPositionValid()) + if (!spawnCreature->IsPositionValid()) { sLog.outError("Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); @@ -3790,7 +3795,7 @@ void Spell::EffectSummonGuardian(uint32 i) return; } - if(duration > 0) + if (duration > 0) spawnCreature->SetDuration(duration); spawnCreature->SetOwnerGUID(m_caster->GetGUID()); @@ -3816,10 +3821,10 @@ void Spell::EffectSummonGuardian(uint32 i) void Spell::EffectTeleUnitsFaceCaster(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(unitTarget->isInFlight()) + if (unitTarget->isInFlight()) return; float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); @@ -3832,10 +3837,10 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i) void Spell::EffectLearnSkill(uint32 i) { - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - if(damage < 0) + if (damage < 0) return; uint32 skillid = m_spellInfo->EffectMiscValue[i]; @@ -3845,11 +3850,11 @@ void Spell::EffectLearnSkill(uint32 i) void Spell::EffectAddHonor(uint32 /*i*/) { - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; // not scale value for item based reward (/10 value expected) - if(m_CastItem) + if (m_CastItem) { ((Player*)unitTarget)->RewardHonor(NULL, 1, damage / 10); sLog.outError("SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(),((Player*)unitTarget)->GetGUIDLow()); @@ -3857,7 +3862,7 @@ void Spell::EffectAddHonor(uint32 /*i*/) } // do not allow to add too many honor for player (50 * 21) = 1040 at level 70, or (50 * 31) = 1550 at level 80 - if( damage <= 50) + if (damage <= 50) { uint32 honor_reward = MaNGOS::Honor::hk_honor_at_level(unitTarget->getLevel(), damage); ((Player*)unitTarget)->RewardHonor(NULL, 1, honor_reward); @@ -3873,7 +3878,7 @@ void Spell::EffectAddHonor(uint32 /*i*/) void Spell::EffectTradeSkill(uint32 /*i*/) { - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; // uint32 skillid = m_spellInfo->EffectMiscValue[i]; // uint16 skillmax = ((Player*)unitTarget)->(skillid); @@ -3882,7 +3887,7 @@ void Spell::EffectTradeSkill(uint32 /*i*/) void Spell::EffectEnchantItemPerm(uint32 effect_idx) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; if (!itemTarget) return; @@ -3897,15 +3902,15 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx) return; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) + if (!pEnchant) return; // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) + if (!item_owner) return; - if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + if (item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), @@ -3924,7 +3929,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx) void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; if (!itemTarget) return; @@ -3936,7 +3941,7 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) return; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) + if (!pEnchant) return; // support only enchantings with add socket in this slot @@ -3944,13 +3949,13 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) bool add_socket = false; for(int i = 0; i < 3; ++i) { - if(pEnchant->type[i]==ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET) + if (pEnchant->type[i]==ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET) { add_socket = true; break; } } - if(!add_socket) + if (!add_socket) { sLog.outError("Spell::EffectEnchantItemPrismatic: attempt apply enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u) but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not suppoted yet.", m_spellInfo->Id,SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC,ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET); @@ -3960,10 +3965,10 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) + if (!item_owner) return; - if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + if (item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), @@ -3982,18 +3987,18 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) void Spell::EffectEnchantItemTmp(uint32 i) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player* p_caster = (Player*)m_caster; - if(!itemTarget) + if (!itemTarget) return; uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; // Shaman Rockbiter Weapon - if(i==0 && m_spellInfo->Effect[1]==SPELL_EFFECT_DUMMY) + if (i==0 && m_spellInfo->Effect[1]==SPELL_EFFECT_DUMMY) { int32 enchnting_damage = m_currentBasePoints[1]+1; @@ -5188,7 +5193,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) return; } // Demonic Empowerment - case 47193: + case 47193: { if(!unitTarget) return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e3c88796c..5155a3270 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8419" + #define REVISION_NR "8420" #endif // __REVISION_NR_H__ From db1c9924a9ca787db5a39ac2839ed20447fdaf5e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 26 Aug 2009 03:45:25 +0400 Subject: [PATCH 10/12] [8421] Propertly skip unused data in CMSG_LOOT_RELEASE for avoid warning spam. --- src/game/LootHandler.cpp | 3 +-- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index da7c2bb6a..274a7f94f 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -256,8 +256,7 @@ void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data ) // cheaters can modify lguid to prevent correct apply loot release code and re-loot // use internal stored guid - //uint64 lguid; - //recv_data >> lguid; + recv_data.read_skip(); // guid; if(uint64 lguid = GetPlayer()->GetLootGUID()) DoLootRelease(lguid); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5155a3270..b870107c0 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8420" + #define REVISION_NR "8421" #endif // __REVISION_NR_H__ From 45dd7140b5640bc8a41e4f7d89e70b2c15278706 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 26 Aug 2009 08:18:30 +0400 Subject: [PATCH 11/12] [8422] Implement far sight like spells work for long distance. * Added basic infrastructure for visibility update in case difference player and current view point. Just for note: seletect additional arg way beacuse repeatable search object will slow but store pointer will not safe, so use middle case: get view point pointer early as possible at visibility updates. * Implement dynamic object and creature activisation while it's target of far sight spell effect * Use this for SPELL_AURA_BIND_SIGHT, SPELL_AURA_FAR_SIGHT and SPELL_EFFECT_ADD_FARSIGHT. * Note2: some spyglass like spells let look _around_ at long distance, this hard implement in current grid loading system Without additional changes and not implemented (you will see empty area without creatures in likes case) * Also fixed warning spam at CMSG_MOVE_SET_CAN_FLY_ACK receive by use proper packet sructure reading. --- src/game/AggressorAI.cpp | 2 +- src/game/Corpse.cpp | 4 +- src/game/Corpse.h | 2 +- src/game/Creature.h | 2 +- src/game/CreatureEventAI.cpp | 2 +- src/game/DynamicObject.cpp | 46 +++++++++++++------ src/game/DynamicObject.h | 7 +-- src/game/GameObject.cpp | 4 +- src/game/GameObject.h | 2 +- src/game/GridNotifiers.cpp | 35 +++++++++------ src/game/GridNotifiers.h | 6 +-- src/game/GridNotifiersImpl.h | 19 +++++--- src/game/Group.cpp | 2 +- src/game/GuardAI.cpp | 2 +- src/game/MiscHandler.cpp | 12 ++--- src/game/Object.cpp | 10 +++++ src/game/Object.h | 6 ++- src/game/ObjectAccessor.cpp | 86 ++++++++++++++++++++++-------------- src/game/ObjectAccessor.h | 1 + src/game/PetAI.cpp | 2 +- src/game/Player.cpp | 48 +++++++++++++++----- src/game/Player.h | 7 +-- src/game/Spell.cpp | 6 +-- src/game/SpellEffects.cpp | 11 +++-- src/game/TotemAI.cpp | 2 +- src/game/Unit.cpp | 38 +++++++--------- src/game/Unit.h | 6 +-- src/shared/revision_nr.h | 2 +- 28 files changed, 228 insertions(+), 144 deletions(-) diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index c1a544d5d..4d1b9c427 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -141,7 +141,7 @@ bool AggressorAI::IsVisible(Unit *pl) const { return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_SIGHT_MONSTER)) - && pl->isVisibleForOrDetect(m_creature,true); + && pl->isVisibleForOrDetect(m_creature,m_creature,true); } void diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 3115a9473..17f76c74d 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -227,7 +227,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) return true; } -bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const +bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const { - return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); + return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(viewPoint, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); } diff --git a/src/game/Corpse.h b/src/game/Corpse.h index c044b339e..b0fc146ed 100644 --- a/src/game/Corpse.h +++ b/src/game/Corpse.h @@ -74,7 +74,7 @@ class Corpse : public WorldObject GridPair const& GetGrid() const { return m_grid; } void SetGrid(GridPair const& grid) { m_grid = grid; } - bool isVisibleForInState(Player const* u, bool inVisibleList) const; + bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const; Loot loot; // remove insignia ONLY at BG Player* lootRecipient; diff --git a/src/game/Creature.h b/src/game/Creature.h index 94743f54e..ede6c61dc 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -681,7 +681,7 @@ class MANGOS_DLL_SPEC Creature : public Unit void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; } - bool isActiveObject() const { return m_isActiveObject; } + bool isActiveObject() const { return m_isActiveObject || HasAuraType(SPELL_AURA_BIND_SIGHT) || HasAuraType(SPELL_AURA_FAR_SIGHT); } void SetActiveObjectState(bool on); protected: diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index c2df6c436..e70b153ff 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -1116,7 +1116,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff) bool CreatureEventAI::IsVisible(Unit *pl) const { return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_SIGHT_MONSTER)) - && pl->isVisibleForOrDetect(m_creature,true); + && pl->isVisibleForOrDetect(m_creature,m_creature,true); } inline Unit* CreatureEventAI::SelectUnit(AttackingTarget target, uint32 position) diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index bf81f6dc6..584e89af9 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -25,8 +25,9 @@ #include "GridNotifiers.h" #include "CellImpl.h" #include "GridNotifiersImpl.h" +#include "SpellMgr.h" -DynamicObject::DynamicObject() : WorldObject() +DynamicObject::DynamicObject() : WorldObject(), m_isActiveObject(false) { m_objectType |= TYPEMASK_DYNAMICOBJECT; m_objectTypeId = TYPEID_DYNAMICOBJECT; @@ -81,6 +82,11 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 m_radius = radius; m_effIndex = effIndex; m_spellId = spellId; + + // set to active for far sight case + if(SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId)) + m_isActiveObject = IsSpellHaveEffect(spellEntry,SPELL_EFFECT_ADD_FARSIGHT); + return true; } @@ -107,20 +113,24 @@ void DynamicObject::Update(uint32 p_time) else deleteThis = true; - // TODO: make a timer and update this in larger intervals - CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); + // have radius and work as persistent effect + if(m_radius) + { + // TODO: make a timer and update this in larger intervals + CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); - MaNGOS::DynamicObjectUpdater notifier(*this, caster); + MaNGOS::DynamicObjectUpdater notifier(*this, caster); - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *GetMap()); - cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap()); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap()); + } if(deleteThis) { @@ -143,7 +153,15 @@ void DynamicObject::Delay(int32 delaytime) (*iunit)->DelayAura(m_spellId, m_effIndex, delaytime); } -bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const +bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const { - return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); + if(!IsInWorld() || !u->IsInWorld()) + return false; + + // always seen by owner + if(GetCasterGUID()==u->GetGUID()) + return true; + + // normal case + return IsWithinDistInMap(viewPoint, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); } diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index 3db328055..066361b8c 100644 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -46,7 +46,7 @@ class DynamicObject : public WorldObject void AddAffected(Unit *unit) { m_affected.insert(unit); } void RemoveAffected(Unit *unit) { m_affected.erase(unit); } void Delay(int32 delaytime); - bool isVisibleForInState(Player const* u, bool inVisibleList) const; + bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const; void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); } void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); } @@ -56,15 +56,16 @@ class DynamicObject : public WorldObject GridReference &GetGridRef() { return m_gridRef; } - bool isActiveObject() const { return false; } + bool isActiveObject() const { return m_isActiveObject; } protected: uint32 m_spellId; uint32 m_effIndex; int32 m_aliveDuration; time_t m_nextThinkTime; - float m_radius; + float m_radius; // radius apply persistent effect, 0 = no persistent effect AffectedSet m_affected; private: GridReference m_gridRef; + bool m_isActiveObject; }; #endif diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index ad8c23ea6..6ddd5a22a 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -690,7 +690,7 @@ void GameObject::SaveRespawnTime() objmgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime); } -bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const +bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const { // Not in world if(!IsInWorld() || !u->IsInWorld()) @@ -717,7 +717,7 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const } // check distance - return IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject() + + return IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); } diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 25ce83d6e..11d9b3160 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -670,7 +670,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target); - bool isVisibleForInState(Player const* u, bool inVisibleList) const; + bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const; GameObject* LookupFishingHoleAround(float range); diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index 1aefbcb4a..5ff6d5d79 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -30,13 +30,16 @@ using namespace MaNGOS; void MaNGOS::PlayerNotifier::Visit(PlayerMapType &m) { + WorldObject const* viewPoint = i_player.GetViewPoint(); + for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) { - if( iter->getSource() == &i_player ) + Player* player = iter->getSource(); + if( player == &i_player ) continue; - iter->getSource()->UpdateVisibilityOf(&i_player); - i_player.UpdateVisibilityOf(iter->getSource()); + player->UpdateVisibilityOf(player->GetViewPoint(),&i_player); + i_player.UpdateVisibilityOf(viewPoint,player); } } @@ -45,24 +48,28 @@ VisibleChangesNotifier::Visit(PlayerMapType &m) { for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) { - if(iter->getSource() == &i_object) + Player* player = iter->getSource(); + if(player == &i_object) continue; - iter->getSource()->UpdateVisibilityOf(&i_object); + player->UpdateVisibilityOf(player->GetViewPoint(),&i_object); } } void VisibleNotifier::Visit(PlayerMapType &m) { + WorldObject const* viewPoint = i_player.GetViewPoint(); + for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) { - if( iter->getSource() == &i_player ) + Player* player = iter->getSource(); + if( player == &i_player ) continue; - iter->getSource()->UpdateVisibilityOf(&i_player); - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); - i_clientGUIDs.erase(iter->getSource()->GetGUID()); + player->UpdateVisibilityOf(player->GetViewPoint(),&i_player); + i_player.UpdateVisibilityOf(viewPoint,player,i_data,i_data_updates,i_visibleNow); + i_clientGUIDs.erase(player->GetGUID()); } } @@ -77,8 +84,9 @@ VisibleNotifier::Notify() { if(i_clientGUIDs.find((*itr)->GetGUID())!=i_clientGUIDs.end()) { - (*itr)->UpdateVisibilityOf(&i_player); - i_player.UpdateVisibilityOf((*itr),i_data,i_data_updates,i_visibleNow); + // ignore far sight case + (*itr)->UpdateVisibilityOf((*itr),&i_player); + i_player.UpdateVisibilityOf(&i_player,(*itr),i_data,i_data_updates,i_visibleNow); i_clientGUIDs.erase((*itr)->GetGUID()); } } @@ -121,9 +129,8 @@ VisibleNotifier::Notify() if(!IS_PLAYER_GUID(*iter)) continue; - Player* plr = ObjectAccessor::GetPlayer(i_player,*iter); - if(plr) - plr->UpdateVisibilityOf(&i_player); + if (Player* plr = ObjectAccessor::GetPlayer(i_player,*iter)) + plr->UpdateVisibilityOf(plr->GetViewPoint(),&i_player); } } diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index ae34ed7e0..32454762d 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -778,7 +778,7 @@ namespace MaNGOS return u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u) - && u->isVisibleForOrDetect(i_funit, false); + && u->isVisibleForOrDetect(i_funit,i_funit,false); } private: WorldObject const* i_obj; @@ -827,7 +827,7 @@ namespace MaNGOS bool operator()(Unit* u) { if( u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) && - !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,false) ) + !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,i_funit,false) ) { i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check return true; @@ -863,7 +863,7 @@ namespace MaNGOS return false; if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isTotem()) return false; - if (!i_hitHidden && !u->isVisibleForOrDetect(i_funit, false)) + if (!i_hitHidden && !u->isVisibleForOrDetect(i_funit, i_funit, false)) return false; if(( i_targetForPlayer ? !i_funit->IsFriendlyTo(u) : i_funit->IsHostileTo(u) )&& i_obj->IsWithinDistInMap(u, i_range)) diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 583732a65..8d2433ce3 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -31,9 +31,11 @@ template inline void MaNGOS::VisibleNotifier::Visit(GridRefManager &m) { + WorldObject const* viewPoint = i_player.GetViewPoint(); + for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) { - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + i_player.UpdateVisibilityOf(viewPoint,iter->getSource(),i_data,i_data_updates,i_visibleNow); i_clientGUIDs.erase(iter->getSource()->GetGUID()); } } @@ -64,10 +66,10 @@ MaNGOS::PlayerRelocationNotifier::Visit(PlayerMapType &m) } } -inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) +inline void PlayerCreatureRelocationWorker(Player* pl, WorldObject const* viewPoint, Creature* c) { // update creature visibility at player/creature move - pl->UpdateVisibilityOf(c); + pl->UpdateVisibilityOf(viewPoint,c); // Creature AI reaction if(!c->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) @@ -98,9 +100,11 @@ MaNGOS::PlayerRelocationNotifier::Visit(CreatureMapType &m) if(!i_player.isAlive() || i_player.isInFlight()) return; + WorldObject const* viewPoint = i_player.GetViewPoint(); + for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - if( iter->getSource()->isAlive()) - PlayerCreatureRelocationWorker(&i_player,iter->getSource()); + if (iter->getSource()->isAlive()) + PlayerCreatureRelocationWorker(&i_player,viewPoint,iter->getSource()); } template<> @@ -111,8 +115,9 @@ MaNGOS::CreatureRelocationNotifier::Visit(PlayerMapType &m) return; for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - if( iter->getSource()->isAlive() && !iter->getSource()->isInFlight()) - PlayerCreatureRelocationWorker(iter->getSource(), &i_creature); + if (Player* player = iter->getSource()) + if (player->isAlive() && !player->isInFlight()) + PlayerCreatureRelocationWorker(player, player->GetViewPoint(), &i_creature); } template<> diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 2513f0ac3..5c83df614 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -973,7 +973,7 @@ void Group::UpdatePlayerOutOfRange(Player* pPlayer) for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next()) { player = itr->getSource(); - if (player && player != pPlayer && !pPlayer->isVisibleFor(player)) + if (player && player != pPlayer && !pPlayer->isVisibleFor(player,player->GetViewPoint())) player->GetSession()->SendPacket(&data); } } diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 5dcbb5a23..e87f5812b 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -126,7 +126,7 @@ void GuardAI::UpdateAI(const uint32 /*diff*/) bool GuardAI::IsVisible(Unit *pl) const { return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_SIGHT_GUARDER)) - && pl->isVisibleForOrDetect(m_creature,true); + && pl->isVisibleForOrDetect(m_creature,m_creature,true); } void GuardAI::AttackStart(Unit *u) diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index fc797944b..e8f907f90 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1456,13 +1456,15 @@ void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket & recv_data ) sLog.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK"); //recv_data.hexlike(); - uint64 guid; - uint32 unk; - uint32 flags; + recv_data.read_skip(); // guid + recv_data.read_skip(); // unk - recv_data >> guid >> unk >> flags; + MovementInfo movementInfo; + ReadMovementInfo(recv_data, &movementInfo); - _player->m_movementInfo.SetMovementFlags(MovementFlags(flags)); + recv_data.read_skip(); // unk2 + + _player->m_movementInfo.SetMovementFlags(movementInfo.GetMovementFlags()); } void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */) diff --git a/src/game/Object.cpp b/src/game/Object.cpp index e370e4be7..16017389a 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1359,6 +1359,16 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const return (( angle >= lborder ) && ( angle <= rborder )); } +bool WorldObject::isInFrontInMap(WorldObject const* target, float distance, float arc) const +{ + return IsWithinDistInMap(target, distance) && HasInArc( arc, target ); +} + +bool WorldObject::isInBackInMap(WorldObject const* target, float distance, float arc) const +{ + return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); +} + void WorldObject::GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const { if(distance == 0) diff --git a/src/game/Object.h b/src/game/Object.h index 1a697fe1d..265d184a7 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -445,6 +445,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object float GetAngle( const WorldObject* obj ) const; float GetAngle( const float x, const float y ) const; bool HasInArc( const float arcangle, const WorldObject* obj ) const; + bool isInFrontInMap(WorldObject const* target,float distance, float arc = M_PI) const; + bool isInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const; virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units @@ -471,10 +473,10 @@ class MANGOS_DLL_SPEC WorldObject : public Object void AddObjectToRemoveList(); // main visibility check function in normal case (ignore grey zone distance check) - bool isVisibleFor(Player const* u) const { return isVisibleForInState(u,false); } + bool isVisibleFor(Player const* u, WorldObject const* viewPoint) const { return isVisibleForInState(u,viewPoint,false); } // low level function for visibility change code, must be define in all main world object subclasses - virtual bool isVisibleForInState(Player const* u, bool inVisibleList) const = 0; + virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const = 0; void SetMap(Map * map); Map * GetMap() const { ASSERT(m_currMap); return m_currMap; } diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 58c220f8e..79b9d9c02 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -90,43 +90,61 @@ ObjectAccessor::GetCorpse(WorldObject const &u, uint64 guid) return ret; } +WorldObject* ObjectAccessor::GetWorldObject(WorldObject const &p, uint64 guid) +{ + switch(GUID_HIPART(guid)) + { + case HIGHGUID_PLAYER: return FindPlayer(guid); + case HIGHGUID_GAMEOBJECT: return p.GetMap()->GetGameObject(guid); + case HIGHGUID_UNIT: return p.GetMap()->GetCreature(guid); + case HIGHGUID_PET: return GetPet(guid); + case HIGHGUID_VEHICLE: return GetVehicle(guid); + case HIGHGUID_DYNAMICOBJECT:return p.GetMap()->GetDynamicObject(guid); + case HIGHGUID_TRANSPORT: return NULL; + case HIGHGUID_CORPSE: return GetCorpse(p,guid); + case HIGHGUID_MO_TRANSPORT: return NULL; + default: break; + } + + return NULL; +} + Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const &p, uint64 guid, uint32 typemask) { - Object *obj = NULL; - - if(typemask & TYPEMASK_PLAYER) + switch(GUID_HIPART(guid)) { - obj = FindPlayer(guid); - if(obj) - return obj; - } - - if(typemask & TYPEMASK_UNIT) - { - obj = GetCreatureOrPetOrVehicle(p,guid); - if(obj) - return obj; - } - - if(typemask & TYPEMASK_GAMEOBJECT) - { - obj = p.GetMap()->GetGameObject(guid); - if(obj) - return obj; - } - - if(typemask & TYPEMASK_DYNAMICOBJECT) - { - obj = p.GetMap()->GetDynamicObject(guid); - if(obj) - return obj; - } - - if(typemask & TYPEMASK_ITEM && p.GetTypeId() == TYPEID_PLAYER) - { - obj = ((Player const &)p).GetItemByGuid( guid ); - if(obj) - return obj; + case HIGHGUID_ITEM: + if(typemask & TYPEMASK_ITEM && p.GetTypeId() == TYPEID_PLAYER) + return ((Player const &)p).GetItemByGuid( guid ); + break; + case HIGHGUID_PLAYER: + if(typemask & TYPEMASK_PLAYER) + return FindPlayer(guid); + break; + case HIGHGUID_GAMEOBJECT: + if(typemask & TYPEMASK_GAMEOBJECT) + return p.GetMap()->GetGameObject(guid); + break; + case HIGHGUID_UNIT: + if(typemask & TYPEMASK_UNIT) + return p.GetMap()->GetCreature(guid); + break; + case HIGHGUID_PET: + if(typemask & TYPEMASK_UNIT) + return GetPet(guid); + break; + case HIGHGUID_VEHICLE: + if(typemask & TYPEMASK_UNIT) + return GetVehicle(guid); + break; + case HIGHGUID_DYNAMICOBJECT: + if(typemask & TYPEMASK_DYNAMICOBJECT) + return p.GetMap()->GetDynamicObject(guid); + break; + case HIGHGUID_TRANSPORT: + case HIGHGUID_CORPSE: + case HIGHGUID_MO_TRANSPORT: + break; } return NULL; diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 6ed1b26cf..cf223ebc9 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -142,6 +142,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::SingletonIsWithinDist(u,sWorld.getConfig(CONFIG_SIGHT_GUARDER)) - && u->isVisibleForOrDetect(m_creature,true); + && u->isVisibleForOrDetect(m_creature,m_creature,true); } void PetAI::UpdateAllies() diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 51bb78d16..d1f59bb9f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16794,13 +16794,15 @@ void Player::HandleStealthedUnitsDetection() cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap()); cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap()); + WorldObject const* viewPoint = GetViewPoint(); + for (std::list::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i) { if((*i)==this) continue; bool hasAtClient = HaveAtClient((*i)); - bool hasDetected = (*i)->isVisibleForOrDetect(this, true); + bool hasDetected = (*i)->isVisibleForOrDetect(this, viewPoint, true); if (hasDetected) { @@ -17884,6 +17886,17 @@ void Player::ReportedAfkBy(Player* reporter) } } +WorldObject const* Player::GetViewPoint() const +{ + if(uint64 far_sight = GetFarSight()) + { + WorldObject const* viewPoint = ObjectAccessor::GetWorldObject(*this,far_sight); + return viewPoint ? viewPoint : this; // always expected not NULL + } + else + return this; +} + bool Player::IsVisibleInGridForPlayer( Player* pl ) const { // gamemaster in GM mode see all, including ghosts @@ -17949,11 +17962,11 @@ bool Player::IsVisibleGloballyFor( Player* u ) const return true; } -void Player::UpdateVisibilityOf(WorldObject* target) +void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target) { if(HaveAtClient(target)) { - if(!target->isVisibleForInState(this, true)) + if(!target->isVisibleForInState(this, viewPoint, true)) { target->DestroyForPlayer(this); m_clientGUIDs.erase(target->GetGUID()); @@ -17966,7 +17979,7 @@ void Player::UpdateVisibilityOf(WorldObject* target) } else { - if(target->isVisibleForInState(this,false)) + if(target->isVisibleForInState(this, viewPoint, false)) { target->SendUpdateToPlayer(this); if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport()) @@ -18002,11 +18015,11 @@ inline void UpdateVisibilityOf_helper(std::set& s64, GameObject* target) } template -void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow) +void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow) { if(HaveAtClient(target)) { - if(!target->isVisibleForInState(this,true)) + if(!target->isVisibleForInState(this,viewPoint,true)) { target->BuildOutOfRangeUpdateBlock(&data); m_clientGUIDs.erase(target->GetGUID()); @@ -18019,7 +18032,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& } else { - if(target->isVisibleForInState(this,false)) + if(target->isVisibleForInState(this,viewPoint,false)) { visibleNow.insert(target); target->BuildUpdate(data_updates); @@ -18034,11 +18047,11 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& } } -template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); void Player::InitPrimaryProfessions() { @@ -20566,3 +20579,14 @@ bool Player::HasMovementFlag( MovementFlags f ) const { return m_movementInfo.HasMovementFlag(f); } + +void Player::SetFarSightGUID( uint64 guid ) +{ + if(GetFarSight()==guid) + return; + + SetUInt64Value(PLAYER_FARSIGHT, guid); + + // need triggering load grids around new view point + ObjectAccessor::UpdateVisibilityForPlayer(this); +} diff --git a/src/game/Player.h b/src/game/Player.h index 0782088e2..f314fd36f 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2084,7 +2084,7 @@ class MANGOS_DLL_SPEC Player : public Unit void ExitVehicle(Vehicle *vehicle); uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); } - void SetFarSightGUID(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); } + void SetFarSightGUID(uint64 guid); // Transports Transport * GetTransport() const { return m_transport; } @@ -2122,13 +2122,14 @@ class MANGOS_DLL_SPEC Player : public Unit bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); } + WorldObject const* GetViewPoint() const; bool IsVisibleInGridForPlayer(Player* pl) const; bool IsVisibleGloballyFor(Player* pl) const; - void UpdateVisibilityOf(WorldObject* target); + void UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target); template - void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); + void UpdateVisibilityOf(WorldObject const* viewPoint,T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); // Stealth detection system void HandleStealthedUnitsDetection(); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 1c745f496..24b155e62 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1194,7 +1194,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) { // for delayed spells ignore not visible explicit target if (m_spellInfo->speed > 0.0f && unit == m_targets.getUnitTarget() && - !unit->isVisibleForOrDetect(m_caster,false)) + !unit->isVisibleForOrDetect(m_caster,m_caster,false)) { realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); return; @@ -1204,9 +1204,9 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if (!(m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH)) unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - // can cause back attack (if detected) + // can cause back attack (if detected), stealth removed at Spell::cast if spell break it if (!(m_spellInfo->AttributesEx & SPELL_ATTR_EX_NO_INITIAL_AGGRO) && !IsPositiveSpell(m_spellInfo->Id) && - m_caster->isVisibleForOrDetect(unit,false)) // stealth removed at Spell::cast if spell break it + m_caster->isVisibleForOrDetect(unit,unit,false)) { // use speedup check to avoid re-remove after above lines if (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index b323738f3..93fd6dc03 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3634,10 +3634,14 @@ void Spell::EffectPickPocket(uint32 /*i*/) void Spell::EffectAddFarsight(uint32 i) { - float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + int32 duration = GetSpellDuration(m_spellInfo); DynamicObject* dynObj = new DynamicObject; - if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + + // set radius to 0: spell not expected to work as persistent aura + if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, 0)) { delete dynObj; return; @@ -3646,8 +3650,7 @@ void Spell::EffectAddFarsight(uint32 i) dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); m_caster->AddDynObject(dynObj); m_caster->GetMap()->Add(dynObj); - if(m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->SetFarSightGUID(dynObj->GetGUID()); + ((Player*)m_caster)->SetFarSightGUID(dynObj->GetGUID()); } void Spell::EffectSummonWild(uint32 i) diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 6b1344140..b826bef03 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -76,7 +76,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) if( !victim || !victim->isTargetableForAttack() || !m_creature->IsWithinDistInMap(victim, max_range) || - m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature,false) ) + m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature,m_creature,false) ) { CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(),m_creature->GetPositionY())); Cell cell(p); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index c66325b6b..802c949f1 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3193,21 +3193,11 @@ Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const return NULL; } -bool Unit::isInFrontInMap(Unit const* target, float distance, float arc) const -{ - return IsWithinDistInMap(target, distance) && HasInArc( arc, target ); -} - void Unit::SetInFront(Unit const* target) { SetOrientation(GetAngle(target)); } -bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const -{ - return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); -} - bool Unit::isInAccessablePlaceFor(Creature const* c) const { if(IsInWater()) @@ -9272,7 +9262,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) return gain; } -bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, bool is3dDistance) const +bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList, bool is3dDistance) const { if(!u) return false; @@ -9319,16 +9309,20 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, if(GetCharmerOrOwnerGUID()==u->GetGUID()) return true; + // always seen by far sight caster + if( u->GetTypeId()==TYPEID_PLAYER && ((Player*)u)->GetFarSight()==GetGUID()) + return true; + // different visible distance checks if(u->isInFlight()) // what see player in flight { // use object grey distance for all (only see objects any way) - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) + if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) return false; } else if(!isAlive()) // distance for show body { - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) + if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) return false; } else if(GetTypeId()==TYPEID_PLAYER) // distance for show player @@ -9336,26 +9330,26 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, if(u->GetTypeId()==TYPEID_PLAYER) { // Players far than max visible distance for player or not in our map are not visible too - if (!at_same_transport && !IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) + if (!at_same_transport && !IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) return false; } else { // Units far than max visible distance for creature or not in our map are not visible too - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) + if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) return false; } } else if(GetCharmerOrOwnerGUID()) // distance for show pet/charmed { // Pet/charmed far than max visible distance for player or not in our map are not visible too - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) + if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) return false; } else // distance for show creature { // Units far than max visible distance for creature or not in our map are not visible too - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) + if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) return false; } @@ -9463,7 +9457,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, float visibleDistance = (u->GetTypeId() == TYPEID_PLAYER) ? MAX_PLAYER_STEALTH_DETECT_RANGE : ((Creature const*)u)->GetAttackDistance(this); //Always invisible from back (when stealth detection is on), also filter max distance cases - bool isInFront = u->isInFrontInMap(this, visibleDistance); + bool isInFront = viewPoint->isInFrontInMap(this, visibleDistance); if(!isInFront) return false; @@ -9490,13 +9484,13 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, visibleDistance = visibleDistance > MAX_PLAYER_STEALTH_DETECT_RANGE ? MAX_PLAYER_STEALTH_DETECT_RANGE : visibleDistance; // recheck new distance - if(visibleDistance <= 0 || !IsWithinDist(u,visibleDistance)) + if(visibleDistance <= 0 || !IsWithinDist(viewPoint,visibleDistance)) return false; } // Now check is target visible with LoS float ox,oy,oz; - u->GetPosition(ox,oy,oz); + viewPoint->GetPosition(ox,oy,oz); return IsWithinLOS(ox,oy,oz); } @@ -10203,9 +10197,9 @@ Unit* Unit::GetUnit(WorldObject& object, uint64 guid) return ObjectAccessor::GetUnit(object,guid); } -bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const +bool Unit::isVisibleForInState( Player const* u, WorldObject const* viewPoint, bool inVisibleList ) const { - return isVisibleForOrDetect(u, false, inVisibleList, false); + return isVisibleForOrDetect(u, viewPoint, false, inVisibleList, false); } uint32 Unit::GetCreatureType() const diff --git a/src/game/Unit.h b/src/game/Unit.h index cbd827e97..30875044d 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1310,21 +1310,19 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const; void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } - bool isInFrontInMap(Unit const* target,float distance, float arc = M_PI) const; void SetInFront(Unit const* target); - bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const; // Visibility system UnitVisibility GetVisibility() const { return m_Visibility; } void SetVisibility(UnitVisibility x); // common function for visibility checks for player/creatures with detection code - bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const; + bool isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList = false, bool is3dDistance = true) const; bool canDetectInvisibilityOf(Unit const* u) const; void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask // virtual functions for all world objects types - bool isVisibleForInState(Player const* u, bool inVisibleList) const; + bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const; // function for low level grid visibility checks in player/creature cases virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b870107c0..7037ab7b2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8421" + #define REVISION_NR "8422" #endif // __REVISION_NR_H__ From 3c22e14e53c086d7c7823f84dd74cfa8164f24df Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 26 Aug 2009 08:47:54 +0400 Subject: [PATCH 12/12] [8423] Fixed typo in mangos.sql. --- sql/mangos.sql | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/mangos.sql b/sql/mangos.sql index d67c83cfb..bd201fc65 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -2832,7 +2832,7 @@ INSERT INTO `mangos_string` VALUES (510,'%d - owner: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (511,'Wrong link type!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (512,'%d - |cffffffff|Hitem:%d:0:0:0:0:0:0:0:0|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(513,'%d - |cffffffff|Hquest:%d:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +(513,'%d - |cffffffff|Hquest:%d:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (514,'%d - |cffffffff|Hcreature_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (515,'%d - |cffffffff|Hcreature:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (516,'%d - |cffffffff|Hgameobject_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7037ab7b2..f34136be4 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8422" + #define REVISION_NR "8423" #endif // __REVISION_NR_H__